- Популярные видео
- Авто
- Видео-блоги
- ДТП, аварии
- Для маленьких
- Еда, напитки
- Животные
- Закон и право
- Знаменитости
- Игры
- Искусство
- Комедии
- Красота, мода
- Кулинария, рецепты
- Люди
- Мото
- Музыка
- Мультфильмы
- Наука, технологии
- Новости
- Образование
- Политика
- Праздники
- Приколы
- Природа
- Происшествия
- Путешествия
- Развлечения
- Ржач
- Семья
- Сериалы
- Спорт
- Стиль жизни
- ТВ передачи
- Танцы
- Технологии
- Товары
- Ужасы
- Фильмы
- Шоу-бизнес
- Юмор
Callback function in JavaScript || JS Interview Questions 2025 #coding #shorts
🔥 Spot the Bug – JavaScript Function Edition
console.log(add(2, 3));
var add = function(a, b) {
return a + b;
};
Looks harmless? Think again 😬
This one-liner fails at runtime with:
❌ TypeError: add is not a function
But why?
💡 Here's the trick:
When you use a function expression with var, only the variable gets hoisted, not the function definition. So at the time of the console.log, add is just undefined — not a function!
✅ Correct Version (Function Declaration):
function add(a, b) {
return a + b;
}
console.log(add(2, 3)); // ✅ 5
✅ OR Fix the Timing (Function Expression):
var add = function(a, b) {
return a + b;
};
console.log(add(2, 3)); // ✅ 5
🧠 Understanding hoisting in JS is critical to avoid subtle bugs like this!
💬 Drop a 🧠 if you learned something new!
🔁 Share with your coding buddy who's still learning functions!
📌 Save this reel for interview prep or review
✅ Follow @codebypc for daily JavaScript bug busters & dev tips!
#JavaScript #CodeBug #FunctionExpression #Hoisting #SpotTheBug #WebDevTips #FrontendChallenge #DeveloperLife #JSBugs #CodeSmart #CleanCode #DebuggingJS #FullStackTips #LearnToCode #TechReels
Видео Callback function in JavaScript || JS Interview Questions 2025 #coding #shorts канала codebypc
console.log(add(2, 3));
var add = function(a, b) {
return a + b;
};
Looks harmless? Think again 😬
This one-liner fails at runtime with:
❌ TypeError: add is not a function
But why?
💡 Here's the trick:
When you use a function expression with var, only the variable gets hoisted, not the function definition. So at the time of the console.log, add is just undefined — not a function!
✅ Correct Version (Function Declaration):
function add(a, b) {
return a + b;
}
console.log(add(2, 3)); // ✅ 5
✅ OR Fix the Timing (Function Expression):
var add = function(a, b) {
return a + b;
};
console.log(add(2, 3)); // ✅ 5
🧠 Understanding hoisting in JS is critical to avoid subtle bugs like this!
💬 Drop a 🧠 if you learned something new!
🔁 Share with your coding buddy who's still learning functions!
📌 Save this reel for interview prep or review
✅ Follow @codebypc for daily JavaScript bug busters & dev tips!
#JavaScript #CodeBug #FunctionExpression #Hoisting #SpotTheBug #WebDevTips #FrontendChallenge #DeveloperLife #JSBugs #CodeSmart #CleanCode #DebuggingJS #FullStackTips #LearnToCode #TechReels
Видео Callback function in JavaScript || JS Interview Questions 2025 #coding #shorts канала codebypc
javascript interview questions javascript interview questions and answers callback in javascript frontend interview questions web developer interview questions and answers async await in javascript promises in javascript objects in javascript js interview questions callback function javascript javascript promises async await javascript namaste javascript season 2 javascript promises explained javascript
Комментарии отсутствуют
Информация о видео
18 июня 2025 г. 19:00:46
00:00:27
Другие видео канала
