Prepare for javascript interview with these ten basic questions

Nuruntahsin
2 min readMay 8, 2021

1.Null vs undefined

In javascript, there are few conditions when we ‘undefined’ such as -if we do not assign the value of the variable, we do not pass parameter inside a function or if trying to find out a property that has not been defined inside an array. Null is something whose value does not exist and the developer assigned it as a value where needed.

2. ‘==’ vs ‘===’ In Js we use ‘==’ to declare value is equal to and only check for the value (not for type). In the case of ‘===’ to be justified both side value and type need to be same.

3. Scope concept. in Javascript when we declare a variable with ‘var’ it has a hoisting power and takes the variable on top of the function and becomes a global variable so its value can be accessed outside of the functional code block. But when we declare a variable with ‘const’ or ‘let’ it confined the variable inside the function code block so we cannot access its value from anywhere.

4.Closure When we call one function inside of another function they create a separate closed system, keeps an external reference variable and return results depending on the reference variable value. Working inside a closed system known as closure.

5. Determiner of the .this In which context the function or method is used that determined the .this keyword in JavaScript. The general rule is to look for the left side of the .this to figure out the determiner. If there is no function or method then the window(JavaScrip running environment) will be the determiner.

6. setTimeout(). Usually Javascript executes functions serially but we can use setTimeout() to execute a function in our preferred time.

console.log('your name');

setTimeout( ()=> {
console.log('your phone number')
}, 7000
)
console.log('your address');

in console, javaScript will first execute ‘your name’ and ‘your address’ first and after 7 sec it will execute ‘your phone number’.

7. arrow function We use the arrow function to make it simple rather than a traditional function. It makes code much cleaner and easy to read.

Traditional function
function add(num 1+num 2){
return num 1 + num 2
};
Fuction as declaring variable
const addTwoNumber = function add(num 1+num 2){
return num 1 + num 2
};
Arrow Function
const addTwoNumber = num => num 1 + num 2;

8.Finding duplicate item from an array
To find the same item from an array and to eliminate it we create a new empty array and push the unique item in that array by using the indexOf() and a conditional function.

9.DOM

Usually the elements inside <body> tag of HTML is called document. In the console of the browser, we can access them by writing JavaScript code inside HTML <body> tag, and then the Document is called JavaScript Object. Converting this document into a JS object is known as DOM-document object model.

10 Event bubble Usually when we give an event handler on a parent tag this also called the event of the child tag. This is known as event bubble.

--

--

Nuruntahsin
0 Followers

I am a very curious learner and passionate designer now focused on changing my design canvas to the computer screen to explore the vast world of web design.