Thanks for writing this! A lot of technical interviewing questions can be tricky or "gotcha" questions, but these are real foundational knowledge and you go into good detail on your answers.
There are a few small issues that might be addressed.
Anonymous Functions
In the description of arrow functions, you say, "Arrow functions can be anonymous". This is true, but it is not unique to arrow functions.
// Fully anonymouswindow.addEventListener('message',function (event){/* ... */});// Technically anonymous (Name assigned automatically)constaddTwo=function (value){returnvalue+2;};// Not anonymous, name separate from variableconstaddFour=functionadd4(value){returnvalue+4;};
We don't usually think of the second one as anonymous because years ago browsers (Chrome first, I think?) started assigning the variable name to an anonymous function to make stack traces more useful, but it is technically anonymous.
this in Arrows
Very minor but depending on the context in which you run your example code, you might not see undefined for the name. A browser's default context is window, and window.name is usually an empty string. The example works as you specify in Node or Deno, though in Bun it will throw an error because the default context is undefined, so this.name cannot be read.
Promise Hell
This is something most people wouldn't take issue with, but I really like promises, so much that my first DEV article was about promises. Nesting .then() is usually an anti-pattern, and in the example case, we can just as easily write this:
I know a lot of people prefer async/await because it's more comfortable for them to read, but promises get some bad press, in my opinion.😭
Prefer MDN
As a last bit, I strongly recommend using MDN over w3schools as a source for definitions and documentation. W3Schools has improved over time, but has been known to have out of date or inaccurate content. MDN is basically the manual for the web.
Again, thank you for writing and sharing this. and I look forward to seeing more content from you!
Hello Samuel!! 😃
I was expecting feedback, but not this much detail!
I'm really happy with all the clarifications and examples you gave me. Thank you so much for taking the time to correct and explain everything. 🫶🏻 The goal of this post is to help others with their interviews, and I definitely don’t want to make things harder for them. 😅
I’ll make sure to fix everything and avoid these mistakes. 💪🏼
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thanks for writing this! A lot of technical interviewing questions can be tricky or "gotcha" questions, but these are real foundational knowledge and you go into good detail on your answers.
There are a few small issues that might be addressed.
Anonymous Functions
In the description of arrow functions, you say, "Arrow functions can be anonymous". This is true, but it is not unique to arrow functions.
We don't usually think of the second one as anonymous because years ago browsers (Chrome first, I think?) started assigning the variable name to an anonymous function to make stack traces more useful, but it is technically anonymous.
this
in ArrowsVery minor but depending on the context in which you run your example code, you might not see
undefined
for the name. A browser's default context iswindow
, and window.name is usually an empty string. The example works as you specify in Node or Deno, though in Bun it will throw an error because the default context isundefined
, sothis.name
cannot be read.Promise Hell
This is something most people wouldn't take issue with, but I really like promises, so much that my first DEV article was about promises. Nesting
.then()
is usually an anti-pattern, and in the example case, we can just as easily write this:I know a lot of people prefer async/await because it's more comfortable for them to read, but promises get some bad press, in my opinion.😭
Prefer MDN
As a last bit, I strongly recommend using MDN over w3schools as a source for definitions and documentation. W3Schools has improved over time, but has been known to have out of date or inaccurate content. MDN is basically the manual for the web.
Again, thank you for writing and sharing this. and I look forward to seeing more content from you!
Hello Samuel!! 😃
I was expecting feedback, but not this much detail!
I'm really happy with all the clarifications and examples you gave me. Thank you so much for taking the time to correct and explain everything. 🫶🏻 The goal of this post is to help others with their interviews, and I definitely don’t want to make things harder for them. 😅
I’ll make sure to fix everything and avoid these mistakes. 💪🏼