The interview questions posted in the article are based on let , rest/spread , default parameter, destructuring, object/template literals , etc introduced in ES 6. Find the output of the code in each question. // Question 1 let a = 2; if (a > 1) { let b = a * 3; console.log(b); for (let i = a; i <= b; i++) { let j = i + 10; console.log(j); } let c = a + b; console.log(c); } // Question 2 function foo() { console.log(a); console.log(b); var a; let b; } foo(); //Question 3 var funcs = []; for (let i = 0; i < 5; i++) { funcs.push(function() { console.log(i); }); } funcs[3](); //Question 4 var a = [2, 3, 4]; var b = [1, ...a, 5]; console.log(b); //Question 5 function foo(x, y, ...z) { console.log(x, y, z); } foo(1, 2, 3, 4, 5); //Question 6 function foo(x = 11, y = 31) { console.log(x + y); } foo();
Explore Javascript core concepts and various Js frameworks. Understand behind the scene working of Javascript engine in easy language with various simple examples.