Some Basic JavaScript Interview Questions

Sahadat Hossain
2 min readMay 10, 2021

Truthy and Falsy Values

1. All string is truthy value other than an empty string.
2. All numbers are truthy value other than Zero
3. If we set values NULL, Undefined, false, and NaN then it will be a falsy value.
4. Empty array and object will truthy value.

Undefined vs NULL

Undefined
1. If we don’t set the value it will be undefined.
2. In function, if you don’t return anything it will undefine.
3. In function, if you don’t pass parameter value it will be undefined.
4. If you set the value as undefined it will be undefined.
5. In an object, if you access a property but not exist in the object it will be undefined.
NULL
1. Whereas, null in JavaScript is an assignment value. You can assign it to a variable.

double equal (==) vs triple equal (===)

  1. triple equal (===) for strict equality and double equal (==) for loose equality.
  2. Triple equal checks both value and type and double equal check just value.

Difference between bind, call & apply.

  • Bind: The bind() method creates a new function when executed later and allowing a passed parameter in an array and any number of arguments.
  • Call: Call invokes the function and allows you to pass in arguments one by one with a comma.
  • Apply: invokes the function and allows you to pass in arguments as an array.

setTimeout and setInterval

  • setTimeout: setTimeout runs the function only one time after interval time.
  • setInterval: setInterval run the function after the given interval of time.

this keyword

The JS this keyword refers to the object it belongs to.
Where it is used
1. Inside a method.
2. Inside a function.
3. Alone.
4. In an event.

--

--