Commonly asked JavaScript interview questions

JavaScript is a high-level, weakly typed, multi-paradigm programming language mainly used in web development. Here I have listed a few Commonly asked JavaScript Interview Questions with their answers.

What is JavaScript?


JavaScript is a high-level, weakly typed, multi-paradigm programming language and is most commonly used in web development.

What are the datatypes in JavaScript?


Number
String
Boolean
Object
Undefined

Is JavaScript a case-sensitive language?


Yes. JavaScript is a case sensitive language.


What is the use of ‘this’ keyword in JavaScript?


In JavaScript, this is used to refer the context which current code is executing.

What is === in JavaScript?


In === (Strict equal) means that the values you are comparing should be of the same datatype.

How to create n object in JavaScript?


var object ={
firstname: "John",
lastname: "Doe"
age: 35,
};

What are anonymous functions? How to define an anonymous function in JavaScript?


An anonymous function is a function without a name.
An anonymous function can be created as shown below.
var fn=function()
{
//do this
}


What are the different types of errors in JavaScript?


JavaScript errors can be classified as Syntax errors, Runtime errors and Logical errors.

What is JavaScript ‘Strict Mode’?


The strict mode has the following features:
-> Prevents, or throws errors, when relatively “unsafe” actions are taken.
-> Prohibits some syntax likely to be defined in future versions of ECMAScript.
-> Fixes mistakes that make it difficult for JavaScript engines to perform optimizations

What are self invoking functions?


The self invoking functions starts automatically without being called.

<script>
(function () {
// Your code here
})();
</script>

What is Callback?

It is a function that has to be executed after completing execution of another function.

What is the difference between var and let in JavaScript?


Variables declared with let has a block scope and the variables declared with var has function scope.

What is NaN?


This property indicates that the value is Not A Number.

If you enjoyed this post, let me know by leaving a comment below.


Leave a Reply

Your email address will not be published.Required fields are marked *