As part of my journey to become a better JavaScript programmer, I need to dive deep into JavaScript foundations. In this article, I'll show you min...
For further actions, you may consider blocking this person and/or reporting abuse
Nice round up. Great to refresh some tricky aspects.
In Q9, I’d like to clarify that let and const are also hoisted but can’t be accessed before declaration due to what is called Temporal Dead Zone.
Ref: jsrocks.org/2015/01/temporal-dead-...
very interesting read, thanks!
Thanks :)
Thank you for the response, I didn't know it, I thought
const
andlet
are not hoisted, but your explanation makes more sense.Thanks for Sharing. Also learn top JavaScript Tricky Interview questions
At first, thanks for all the examples and explanations! When I was taking this quiz, a thought "who ever write code this way?" appeared too many times :) I think these questions are good as a tricksters for A-graders, but if this kind of code somehow had appeared in PR, I would have never approved it
Thank you for the feedback, but can you elaborate more on your response? These questions were made for developers to strengthen their knowledge (even if you know the answer). The examples were made to be very simple, only to understanding the concept behind the question.
Well, my message wasn't about all the questions, most of them cover underlying concept and doesn't contradict to real world. But examples about hoisting or array reference looks like smelly code. Though I didn't check with my IDE and SonarLint that examples, I'm almost sure I'll get warnings.
P.S. english is not my native lang, so I'm bot sure 'bout the tone of voice of my message, hope it's not seems offensive or smth
On the contrary, I glad to hear feedback, even if it negative. I will take your tips to my attention. Thanks
Hi, on number 3 I do not think definition of clousure is correct. Because a closure is not a function that return another function. As per your example is the variable value that gets a reference to param 2. So the variable get close inside the scope and by that the function cant return. In your example the closure refers to value.
I'm not sure you are correct, And I didn't understand completely what you mean. But, I think we say the same thing. I believe it doesn't matter if you know the exact definition of closure "by the book", the most important thing it's to understand the concept.
10x mate :-) , it's always important to refresh the basics.
In Q8 - Running the code in Node will result undefined , see more details :
stackoverflow.com/questions/602986...
Thank you for the response. It's is very helpful. You right, The window object exists only in the browser (client-side). I wanted to show the basic concepts of javascript. The scope of node js it's a little bit different. You can create a
global
variable by doingglobal.length
(not recommended) - but without it, I thinkthis
won't know whatlength
is. if you that in node.js it will work:Thank you so much for this quiz. I have scored 7/10 and last two questions help me to understand hoisting in more clear way. 🤯
Very useful questions that help me revise my JavaScript knowledge. Thank you!
Very happy to hear. Thank you for the comment
Answer to nr 5 is wrong though. It is [1,2,3] because in the function argument you pass the same referrence that you are logging.
Aa dude, my bad, the answer is actually corect, but the anchor takes me to the answer to Q6 and I didn’t realise.
Nice brother. I was also confused when you said hoisting only works for var and then asked to ChatGPT and see comments, which helped me to understand. You should update that hosting part.
Thank you! I glad it helped you. And thank you for sharing the video.