Consider below code snippet – it just has couple of for loops. Everything is same except for the fact that the first for loop uses ‘var’ keyword and second for loop uses ‘let’ keyword. Would there be any difference in ‘console.log’ statements between first loop and second loop? Take your time and answer. Answer: The first loop will print 3 …
Difference between calling a function with new keyword and without new keyword in JavaScript
JavaScript is so flexible, and it allows you to call the same function in different manners. You can call the same function with ‘new’ keyword and without ‘new’ keyword. You can call the same function through an object and not through an object. How you call the function matters a lot and JavaScript would provide completely different results in each …
Asynchronous JS – JavaScript for C# developers
Below content is an excerpt from my book – “JavaScript for C# developers“. Consider the below code snippet, which has just 3 statements and seems to be simple but it is worth analysing it to understand how javascript works with respect to execution of asynchronous code. During the execution phase, JavaScript engine starts executing your code from first statement till last …
How value of ‘this’ is evaluated in JavaScript – Part 2
Below content is an excerpt from my book – “JavaScript for C# developers“. In the last blog post, we’ve discussed how the value of ‘this’ is evaluated in below scenarios Invocation of function through object Invocation of function directly (without any object) If you’ve not read that blog post, I recommend you to read that blog post before proceeding further. …
How value of ‘this’ is evaluated in JavaScript – Part 1
Below content is an excerpt from my book – “JavaScript for C# developers“. As with many things in javascript, the evaluation of the value of ‘this’ keyword in JavaScript is completely different from how it is done in C#. Before discussing about how JS engine evaluates the value of ‘this’ keyword in javascript, let us revisit how ‘this’ works in C#. Consider the below C# code snippet, where we …