- Популярные видео
- Авто
- Видео-блоги
- ДТП, аварии
- Для маленьких
- Еда, напитки
- Животные
- Закон и право
- Знаменитости
- Игры
- Искусство
- Комедии
- Красота, мода
- Кулинария, рецепты
- Люди
- Мото
- Музыка
- Мультфильмы
- Наука, технологии
- Новости
- Образование
- Политика
- Праздники
- Приколы
- Природа
- Происшествия
- Путешествия
- Развлечения
- Ржач
- Семья
- Сериалы
- Спорт
- Стиль жизни
- ТВ передачи
- Танцы
- Технологии
- Товары
- Ужасы
- Фильмы
- Шоу-бизнес
- Юмор
What is the output of these code snippets? JavaScript Interview questions #coding #javascript
ANSWERS 👇👇
1. Answer - foo, undefined
When the method obj.b is called directly on obj, the output will be "foo". This is because this refers to the object that the method is called on, and obj.a is equal to "foo".
When the variable c is assigned the value of obj.b, it is a reference to the function itself and not the object obj. When c is called, it is not called on an object, so this will not refer to obj and the value of this.a is undefined. As a result, the output when calling 'c' will be undefined.
2. Answer - 5, 5, 5, 5, 5
The setTimeout function is called inside of a loop that iterates through the elements in the arr array. The setTimeout function will execute its callback function after a delay of 1000 milliseconds. However, by the time the delay has elapsed and the callback function is called, the loop will have already completed and the value of i will be 5. As a result, the output will be 5 printed five times.
3. Answer: 25 30
The code creates an object obj with properties name and age. Then it creates a new object newObj using the spread operator to copy the properties of obj and then it updates the age property to 30.
The spread operator ... creates a new object with properties copied from the original object.
So, the first console.log statement logs the value of age property of obj which is 25.
And, the second console.log statement logs the value of age property of newObj which is 30.
It doesn't affect the original object obj.
#programming #programminglife #coding #codinglife #html #css #javascript #python #frontend #frontenddeveloper #webdev #webdeveloper #webdevelopment #java #fullstackdeveloper #quiz #jsquiz #iit #btech #jee #internship #job #placement
Видео What is the output of these code snippets? JavaScript Interview questions #coding #javascript канала 4_Programmers
1. Answer - foo, undefined
When the method obj.b is called directly on obj, the output will be "foo". This is because this refers to the object that the method is called on, and obj.a is equal to "foo".
When the variable c is assigned the value of obj.b, it is a reference to the function itself and not the object obj. When c is called, it is not called on an object, so this will not refer to obj and the value of this.a is undefined. As a result, the output when calling 'c' will be undefined.
2. Answer - 5, 5, 5, 5, 5
The setTimeout function is called inside of a loop that iterates through the elements in the arr array. The setTimeout function will execute its callback function after a delay of 1000 milliseconds. However, by the time the delay has elapsed and the callback function is called, the loop will have already completed and the value of i will be 5. As a result, the output will be 5 printed five times.
3. Answer: 25 30
The code creates an object obj with properties name and age. Then it creates a new object newObj using the spread operator to copy the properties of obj and then it updates the age property to 30.
The spread operator ... creates a new object with properties copied from the original object.
So, the first console.log statement logs the value of age property of obj which is 25.
And, the second console.log statement logs the value of age property of newObj which is 30.
It doesn't affect the original object obj.
#programming #programminglife #coding #codinglife #html #css #javascript #python #frontend #frontenddeveloper #webdev #webdeveloper #webdevelopment #java #fullstackdeveloper #quiz #jsquiz #iit #btech #jee #internship #job #placement
Видео What is the output of these code snippets? JavaScript Interview questions #coding #javascript канала 4_Programmers
Комментарии отсутствуют
Информация о видео
17 мая 2024 г. 15:56:41
00:00:25
Другие видео канала




















