JS Interview #11: Scope
Variables with the same name in JavaScript? What will be logged to the console? . . . . . . . . . . . . . . . ....
Variables with the same name in JavaScript? What will be logged to the console? . . . . . . . . . . . . . . . ....
What's the difference between `null` and `undefined` in JavaScript? What will be logged to the console? (think well, then click for the answer and explanation) In the first line, we evaluate null === null and the result is true....
Let's try to reject the promise inside of the JS `try/catch`. Will we catch the error in the `catch` block? (think well, then click for the answer and explanation) Regular try/catch blocks only catch errors that appear in the synchronous code....
What if we call `setTimeout` with 0 delay in JavaScript? Which of the messages will be printed first? (think well, then click for the answer and explanation) In JS, `setTimeout(func, delay)` takes a function `func` and delays its execution by `delay` milliseconds....
Let's find out what鈥檚 the deal with JavaScript arrays. Is `array` an array? (think well, then click for the answer and explanation) In line one we create an array and bind it with the array constant....
`true` or `false`? That is the question... (think well, then click for the answer and explanation) In JS, all functions have access to the internal arguments array that holds all arguments that were passed into the function....
Are there any issues with the `getId` function? What will be logged to the screen? (think well, then click for the answer and explanation) So, getId is an arrow function, thus it doesn鈥檛 have this of its own....
How will the `try/catch` blocks behave? What will be logged to the console? (think well, then click for the answer and explanation) So, we have 2 variables and 2 try/catch blocks that supposedly catch errors and put them into e1 and e2....
Will we see any output? If yes, then what would it be? (think well, then click for the answer and explanation) To answer this question correctly, you need to understand the typecast rules in JS....
What's the correct way to create an array in JS? (think well, then click for the answer and explanation) The first array, a1 is declared using an empty array literal....