Hello friends, In this article, we will discuss about JavaScript Interview Questions and Answers. we will give you the top JavaScript Interview Questions and Answers.
1. What is JavaScript?
JavaScript is the most popular web scripting language. which is used for both client-side and server-side development. supporting object programming abilities, the javascript code can be inserted into HTML pages that can be understood and executed by browsers.
2. What is ECMAScript?
ECMAScript stans for Europea Computer Manufacturers Association Script. which is a scripting language based on javascript.
3. Difference between “==” and “===” operators.
0==false // true, because false is equivalent of 0.
0===false // false, because both operands are of a different type.
2==”2″ //true, auto type coercion, string converted into a number.
2===”2″ // false, since both operands are not of the same type.
4. What are the data types supported by javascript?
Undefined
NULL
Boolean
Object
String
Symbol
Number
5. What is javascript strict mode?
The default behavior of JavaScript is very forgiving if we make a
minor mistake. That means that it will not display any error
messages. But sometimes in development, we need to see all
kinds of errors and warnings in order to debug the code.
6. What is closure?
A closure in JavaScript is a function inside another function. The
the inner function has access to its own variables, the variables
defined in the outer function as well as the global variables.
var a=2; function outer() { var b = 4; function inner() { var c=6; console.log(a + b + c); } inner(); } outer();
7. What is NaN?
In JavaScript, NaN stands for Not a Number. It is a special value
that occurs when we are unable to perform an operation.
For example, what if we try to divide a string using a number
(e.g., “Hello World” / 5)?
8. How can you create an object in Javascript?
var student = { name:"john", age:25 }
9. How can you create an array in javascript?
var x = []; var y = [1,2,3];
10. Define anonymous function?
var showMessage=function() { alert("anonymous function is invoked"); } showMessage();
11. What is this [[[]]];
var myArr = [[[]]];
12. What are the features of javascript?
– Lightweight interpreted programming language.
– cross plateform compatible
– Open source
– Integration with other backend and frontend
– Used especially for the development of network-based applications.
13. What are the scope of a variable in javascript?
There are two scopes of a variable.
Global Scope
Global Scope having global scope are available everywhere in javascript code.
Local Scope
Local variables are accessible only within the function in which they are defined.
14. What are the arrow function in Javascript?
Arrow functions are a short and concise way of writing functions in javascript. the general syntax of an arrow function is as below.
const myFuction = () =>{ console.log("my function"); }