10 Common JS interview questions.

Mehraj Rahman
2 min readMay 16, 2021

Hello, everyone! Hope so you guys are doing great woth code

Diff between == and ===:

In JavaScript == is a comparison operator and === is a strict comparison operator. In simple word == compare two variables without checking their data types. But === compare two variables as well as their data types. Example: 2== “2” will give true where 2===“2” will give false.

Anonymous Function:

If you ever see a function which has been declared without declaring its name then it would be called a anonymous function. Actually we don’t use this function very often unless we exactly know what we are doing.

Truthy and Falsy Values:

You will find them inside of a if statement’s condition, when you want a strict true or false output from if() condition. In JavaScript if/else check the values you will give and it will return true or false. There are some values which will return false and these are called falsy values. they are: false, ‘’, “”, 0, -0, 0n, NaN, null, undefined.
And anything except these are truthy.

Const/let vs var:

This is another issue in JavaScript. You can redeclare var in your code and it is function scoped. Where const and let is block scoped and can’t be redeclared. Also we can update var and let but we can’t update const.

Null vs Undefined:

If you focus on the two names you will get a basic idea about this two. Null represents nothing. This means if you declare a variable with a value of null that means you declared a variable which has no value.
But undefined is different from this. It tells us that something is not defined. When you declare a variable without assigning a value then it will return undefined.

Different between java and JavaScript:

After listening the name JavaScript one question will come to your mind. “Is there any relation between Java and JavaScript?”, unless you are a prodigy.
The answer is, there is no relation between Java and JavaScript at all. Except only one thing, that JavaScript was inspired by Java in it’s early stage.

Features of JavaScript:

JavaScript is a light weight, interpreted programming language. One thing I should mention here, it is a cross platform programming language. It is complimentary and integrated with JAVA.

“this”- keyword in JavaScript:

The JavaScript this keyword is an interesting topic. Usually it refers to the object which it belongs. In a method, this refers to the owner object and in a function, this refers to the global object.

Closure in JavaScript:

In JavaScript, closures are created every time a function is created. To use a closure, simply define a function inside another function and expose it. It’s created whenever a variable that is defined outside the current scope is accessed from within some inner scope. It gives you access to an outer function’s scope from an inner function.

Hope so you enjoyed the article!

--

--