Skip to content

PrgVaibhav/JS_Interview_Questions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 

Repository files navigation

JS Interview Questions and Answers

Want HTML Questions Visit Here

Want CSS Questions Visit Here

We will cover a variety of JS questions ranging from basic to advanced. Let's get started!

Question 1: What is JavaScript?

JavaScript is a scripting language used to create interactive and dynamic web pages. It is often used for client-side scripting, where it is executed in the user's web browser, but it can also be used for server-side scripting with Node.js.

Question 2: What is the difference between "undefined" and "null" in JavaScript?

"Undefined" is a value that is automatically assigned to a variable that has been declared but not assigned a value. "Null" is a value that can be assigned to a variable to indicate that it has no value. In other words, "undefined" means that a variable has not been initialized, while "null" means that a variable has been explicitly set to have no value.

Question 3: What is a closure in JavaScript?

A closure is a function that has access to variables in its outer scope, even after the outer function has returned. Closures are often used to create private variables and functions in JavaScript and can also be used to create functions that can be executed later.

Question 4: What is the "this" keyword in JavaScript?

The "this" keyword in JavaScript refers to the current object that the code is executing within. The value of "this" depends on how a function is called, and it can be set explicitly using methods like call, apply, and bind.

Question 5: What are some of the data types in JavaScript?

JavaScript has six primitive data types: string, number, boolean, null, undefined, and symbol. In addition, there is one complex data type: object.

Question 6: What is the difference between == and === in JavaScript?

== is the equality operator in JavaScript and checks for value equality, while === is the strict equality operator and checks for both value and type equality. For example, 1 == '1' would return true, while 1 === '1' would return false.

Question 7: What is event bubbling in JavaScript?

Event bubbling is the process by which events propagate up the DOM tree from the target element to its parent and ancestor elements. This means that when an event is triggered on an element, it will also be triggered on all of its ancestor elements up to the document root.

Question 8: What is the difference between "var", "let", and "const" in JavaScript?

"var" is the older way of declaring variables in JavaScript, while "let" and "const" were introduced in ES6. "let" is used to declare variables that can be reassigned, while "const" is used to declare variables that cannot be reassigned. In addition, "let" and "const" are block-scoped, while "var" is function-scoped.

Question 9: What is asynchronous programming in JavaScript?

Asynchronous programming in JavaScript allows code to be executed out of order, meaning that code that takes a long time to run can be executed in the background while other code continues to run. This is typically done using callbacks, promises, or async/await.

Question 10: What are some of the new features in ES6 (ECMAScript 2015)?

ES6 introduced many new features to JavaScript, including block-scoped variables with let and const, arrow functions, template literals, default function parameters, rest and spread operators, destructuring assignments, classes, and modules.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published