Javascript Interview Question for Job sicker

Mohammad Osman Goni
3 min readMay 8, 2021
  1. What is True and False value in Javascript?

Many types of build in value used in javascript for True and False.

False Value:

  • 0
  • Undefined
  • Null
  • NAN
  • Empty String (``)
  • false

True Value:

  • All Numeric value of javascript other than 0.
  • All String value other than Empty String.
  • Empty Object
  • Empty Array

Above all Javascript All value are true other than false value

2. Null vs Undefined

Null and Undefined is special value in javascript programming language.

Undefined: Many times we are found Undefined Value. Such as

  • if we are not Initialize any variable than we are found Undefined
  • If we are not return any valid value from function than this function return Undefined Value
  • In Parameter of Function, if we are not pass any argument and Not set any default value for parameter than this parameter return undefined value.
  • if we are access any property from Array or Object that not available in Array or Object than this situation we are found Undefined Value.

Null: null means empty value.

  • if we are means empty for any variable than we set null in this variable.
  • Null is a object type data that mostly use in Object
  • if we use null value in a variable than this variable will not undefined.

3. What is Double equal (==) and Triple Equal (===) deference in javascript.?

Double equal(==)

This is used in compare 2 variable. if we are used double equal than provides output from two variable data type converts in same type and compare between two variable Value. above all double equal provide result from compare between two variable value.

Triple Equal (===)

Triple equal provides result from compare 2 variable data type and value. such as if 2 variables value is ` false and 0` than this is result is false because there are data types no same.

4. Describe Scope for Javascript

Scope is very important topic for javascript developers. Scope means in javascript Any variable accessibility limit. 3 type scope in javascript.

  • Global Scope
  • Function Scope
  • Block Scope

5. What is Global scope, Function scope and Block Scope?

Global Scope:Global scope that if we are declare variable in outdoor of function than this variable access anywhere in the program.

var greeting = 'Hello World!';
function greet() {
console.log(greeting);
}

Function Scope: Global scope that variable declare inside in function. Variable can access only within function. cannot access outdoor function.


function greet() {
var greeting = 'Hello World!';
console.log(greeting);
}

Block Scope: Block scope means if we are declared variable in any a block with let or const , than variable access limit in this block. variable does not access out side of this block.

function add(){
var x=50;
var y=10;
if(1){
const result=x+y;
cosnole.log(result)
}}

6. What is deference of bind(),apply(),call()?

if we want to use a method of anyone Object on another object than we can use bind,apply or call method.

bind ()

Call is the method of using the object to call.
The first parameter is to send that method to the object on which it will be used. bind method return a function. if we are moreover use this method than return function call moreover .

const NewMan=xobject.xmethod.bind(MainObject);
NewMan();
NewMan();

call()

Call is the method of using the object to call.The first argument is to send that method to the object on which it will be used.
Other arguments send in the method must be comma-separated.

call(obj,etc,etc)

apply()

apply is the method of using the object to call.The first argument is to send that method to the object on which it will be used.
Other arguments send in the method must be with array.

apply(obj,[etc,etc])

7. What is window in javascript?

window object is a javascript running environment. A global variable, representing the window in which the script is running, is exposed to JavaScript code. all property to run javascript is available in window Object .we are access use window object any property of javascript.

8. What is Class and Object in Javascript?

Class is a template from which objects are created.Class is declared using class keyword. Example:
class Son{}

Object is a instance of class.Object is created with new keyword mainly.
Son sone1=new Son();

9. What is Hoisting in javascript?

Hoisting means anyone variable declare with var than taking his scope to the upper level , that is to the upper level. this situation we are access anywhere of function for anyone variable that declare with var.

10. What is Closure in Javascript?

if there is one more function inside a function and if that secondary function is returned or used inside the first function, then that function creates a close environment and creates an external variable reference.

--

--