bluehost-banner

Advance JavaScript Interview Questions - Collection 2

Can you explain hoisting?

What is implicit type coercion in JavaScript?

Is JavaScript statically or dynamically typed?

Is JavaScript single or multi-threaded?

What does NaN mean in JavaScript?


What is an IIFE and what are some of its benefits?

What is a pure function?

Can you explain how scope works on a high level?

Can you explain how async / await works in JavaScript and what are the benefits of using it?

What are arrow functions and what are their pros/cons?


Explain WeakSet in JavaScript.


Explain WeakMap in JavaScript.


What is a temporal dead-zone?


What is negative infinity in JavaScript?


Does JavaScript support automatic type conversion?


How can you detect a user’s scrolled location on a page?


If I wanted to insert an element at a specific location inside an array, which method would I use?


What are some ways to create objects in JavaScript?


Can you explain the 3 different error types in JavaScript?


What is event bubbling in JavaScript?


Why are functions 1st class citizens in JavaScript?


Why is using innerHTML a bad practice?


What is event delegation?




Q16. What are the types of JavaScript Function Scope?




Name a few built-in methods.

Ans. JavaScript has several built-in methods which are classified as:


Number Methods – constructor(), toExponential(), toFixed()

Boolean Methods – toSource(), toString(), valueOf()

Date Methods – Date(), getFullYear(), getHours()

Math Methods – abs(), exp(), log()


Q20. How can you submit a form using JS?


In HTML, how many ways are there to involve JS?


Differentiate Cookies, LocalStorage, and sessionStorage.


Explain pop() and shift() methods


In JavaScript, append a new element at the end of the array.

Explain what is a callback in JS.

What is Closure? Give an example.


How to get inner Html of an element in JS?

How can we read elements of an array?

Ans. Syntax:


var num1 = [0, 1, 2, 3, 4];


for (var i = 0; i < num1.length; i++) {


  document.write(num1[i]);


}

What is the possible way to give a comment?

Ans. Syntax:


Single line comment – // Single-line comments.


Multiple line comments – /* Multi Line Comment


Mention HTML DOM mouse events.

Ans. Following are the HTML DOM mouse events:


onclick

ondblclick

mouseout

mouseover

Mouseup

mousemove

mousedown


How do we create an array?


Explain Loops in JavaScript.

What is Inheritance

What is typeof operator?

What is strict mode?


What are the scopes of a variable in JavaScript?


What are the data types supported by JavaScript?


How can you create an object in JavaScript?


What is Callback?



How can you create an Array in JavaScript?


List out the different ways an HTML element can be accessed in a JavaScript code.

Here are the list of ways an HTML element can be accessed in a Javascript code:(i) getElementById(‘idname’): Gets an element by its ID name(ii) getElementsByClass(‘classname’): Gets all the elements that have the given classname.(iii) getElementsByTagName(‘tagname’): Gets all the elements that have the given tag name.(iv) querySelector(): This function takes css style selector and returns the first selected element.




 What is the difference between Local storage & Session storage?

 What is the difference between the operators ‘==‘ & ‘===‘?

 What is an event bubbling in JavaScript?

What are Exports & Imports?

Imports and exports help us to write modular JavaScript code. Using Imports and exports we can split our code into multiple files.


What are all the looping structures in JavaScript?


What are all the types of Pop up boxes available in JavaScript?