Javascript Interview Questions and Answers - 20 | javascript interview questions freshers

preview_player
Показать описание
Javascript interview questions and answers, javascript interview questions, javascript interview coding exercises, javascript interview questions and answers 2020, javascript interview questions and answers 2019, javascript interview, javascript interview prep, javascript in 12 minutes

Javascript interview questions and answers series

Javascript Interview Questions and Answers - Part 1

Javascript Interview Questions and Answers - Part 2

Javascript Interview Questions and Answers - Part 3

Javascript Interview Questions and Answers - Part 4
Рекомендации по теме
Комментарии
Автор

type of a function is 'function'. The reason it is undefined in this scenario is because 'f' is not declared in function scope yet. Not because the function returns nothing

taibui
Автор

Sir can you give me the code for dynamically adding form groups. And bind the values in angular forms.

bhanuprakash
Автор

Question asked to me in interview.

Consider following code snippet:

{
console.time("loop");
for (var i = 0; i < i += 1){
// Do nothing
}
console.timeEnd("loop");
}
The time required to run this code in Google Chrome is considerably more than the time required to run it in Node.js. Explain why this is so, even though both use the v8 JavaScript Engine.

1. Please explain in detail. What is window object here?

Answer mention on a website:
Within a web browser such as Chrome, declaring the variable i outside of any function’s scope makes it global and therefore binds it as a property of the window object. As a result, running this code in a web browser requires repeatedly resolving the property i within the heavily populated window namespace in each iteration of the for loop.

In Node.js, however, declaring any variable outside of any function’s scope binds it only to the module’s own scope (not the window object) which therefore makes it much easier and faster to resolve.

It’s also worth noting that using let instead of var in the for loop declaration can reduce the loop’s run time by over 50%. But such a change assumes you know the difference between let and var and whether this will have an effect on the behavior of your specific loop.

akshaysaini
join shbcf.ru