Загрузка...

The #1 mistake with JS Map & Filter! 🛑 #javascript #coding #programming #quiz

Why is your array empty? or worse... full of undefined? 🕵️‍♂️

The Trap: When using .map(), if you use curly braces { }, you must use the return keyword. If you don't, JavaScript executes the math but doesn't "give it back" to the new array.

The Fix:

Implicit Return: Remove the braces: nums.map(x → x * 2)

Explicit Return: Keep the braces but add return: nums.map(x → { return x * 2 })

Which style do you prefer? Clean arrows 🏹 or explicit returns? 👇

#javascript #codingtips #webdev #programming #softwareengineer #es6 #reactjs #arraymethods #jscheck #shorts

Видео The #1 mistake with JS Map & Filter! 🛑 #javascript #coding #programming #quiz канала CodeCupps
Яндекс.Метрика
Все заметки Новая заметка Страницу в заметки
Страницу в закладки Мои закладки
На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.
О CookiesНапомнить позжеПринять