Some JavaScript Interview Question You Should be known For the Better Position In Interview

shakil ahmed
4 min readMay 8, 2021

Hello Developers, if you have already known javaScript some fundamental topic then I think you should be known that type of question which is always come interview. YES, today I will talk about some interview questions and answer it is very necessary for a javaScript developer who looking for that job.

What is javascript:

javaScript is a programing language. Is a lightweight interpreted and just-in-time compiled programing language with a first-class function.JavaScript can update and change both HTML and CSS. It is basically client-side language.

var, let, const

var changeable and it shares value with the parent scope. let is also changeable but it is not shared value with others. const value not changeable it’s a fixed value.

What is an API

API is an Application Programming Interface. It is a computing interface that defines the interaction between multiple software intermediaries. It is a bridge between the server-side and the client-side. its main work is request and response. we can use API with some method as like get, post, put, delete etc

When and how to use javascript callback function:

when we a funciton call and another function pass that as argument that is callback function.if we needed a call function to another funcion then we can use callback function

// function
function greet(name, callback) {
console.log(‘Hi’ + ‘ ‘ + name);
callback();
}
// callback function
function callMe() {
console.log(‘I am callback function’);
}
// passing function as an argument
greet(‘Shakil’, callMe);

Arrow function, multiple parameter, function body:

Arrow function is one of the features introduced in the ES6 version of JavaScript.it is a cleaner version of function it is declared with => sign and passes multiple or empty parameter and A function body is a compound statement containing the statements that specify what the function does example below

Old function
let x = function(x, y) {
return x * y;
}

Arrow function
let x = (x, y) => {
x * y; // function body
}

simple and cleaner

What are Truthy and Falsy values:

When we are using the If condition then it’s just checking my statement is true or false. But seeing some conditions we understand that value is truthy or falsy. So When the value is truthy or falsy

Falsy Value: number (0), string(“empty”),Undefined,null, NaN.

Truthy Value: number(any number except Zero), string(“any string also a space”), array([]), object({})

Null Vs Undefined:

Undefined:

1. if we are declare something at let or const but we don’t assign a value then it is undefined

let userName;
consol.log(userName)//undefined

2. The function always returns something. when we make a function properly and write just return keyword but we don’t say which one will return.

function add(num1, num2){
console.log(num1 + num2);
return //undefined
}

3.when creating a function with parameter but call the function without pass any parameter

function add(num1, num2){
console.log(num1, num2);
}
add(); //undefined

4.We call an object property but that property not existing in the object as like

const user= {name:”jon”, phone:458421};
console.log(user.age); // undefined

5.Similarly, We call an array index but that index not existing in the array. as like

let ages = [2, 5, 9]
console.log(ages[11]);// undefined

6.If you set the value of something to be undefined

let age = undefined;
const color = undefined;
console.log(age); //undefined
console.log(color); //undefined

Null:

  1. null is a empty or non-existent value. null must be assigned

let a = null;
console.log(a); // null

Double equal (==) vs triple equal (===)

It’s simple to double equal check only value and triple equal check value + type.

const first = 0;
const second = false;

if(first == second){
console.log(“condition is true”);// it’s execute
}
else{
console.log(“condition is false”);
}

//
if(first === second){
console.log(“condition is true”);
}
else{
console.log(“condition is false”); // it’s execute because type are not same
}

Difference between bind, call and apply

bind():

The bind method creates a new function and sets this keyword to the specified object.

Syntax: function.bind(thisArg, optionalArguments)

call():

Calls a function with a provided this. Further arguments are provided as a comma-separated list.

Syntax: function.call(thisArg, arg1, agr2, …)

apply():

Calls a function with a provided this value. Further arguments are provided as a single array.

Syntax: function.apply(thisArg, [arg1, agr2])

Thanx for reading properly..

--

--

shakil ahmed
0 Followers

Hello, I am Shakil Ahmed Front End Developer & I am also working as a MERN developer I Love ❤️ JS.