JavaScript Interview Questions that made me think — Do I really know JavaScript? — Part 2

Javascript tricky interview questions

Photo by James Harrison on Unsplash

What will be printed in console?

It will print:2
2
.length property on function prints the length of arguments a function is expecting.
And if there is any optional argument, then all argument after that will be considered option, not matter if we declare them optional or not.
With that said, it is always a good practice to include optional arguments in the last.

What is the value of this inside a static function?

The value of this inside a static function is class itself.When we log this inside static method whole class will be logged.// Output
class Test {
constructor(lang) {
this.lang = lang;
}
static showName() {
console.log(this, this.lang);
}
}

What will be printed in console?

true
true
true
false

How to check whether the object value is an object or not?

What will be printed in console?

HelloHowHelloHow are you?

What will be printed in console?

When we do .toString() in an array, it will stringily the elements inside it, if it contains primitive values.And toString() also flatten the array.Output:"4,5,6,3,4,5"

What are the three event phases? Write them in the order they occur.
.

1. Capturing phase – the event goes down to the element. 
2. Target phase – the event reached the target element.
3. Bubbling phase – the event bubbles up from the element.
Order Will be 1 then 2 then 3

What will be printed in console?

obj.showLang() will print undefinedx.showLang() will print Vue

What will be printed in console?

112undefined

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store