Tricky JavaScript interview question you need to know
What is JavaScript?
JavaScript is a dynamic computer programming language. It is lightweight and most commonly used as a part of web pages, whose implementations allow client-side script to interact with the user and make dynamic pages. It is an interpreted programming language and object-oriented also.
What are JavaScript Data Types?
There is six basic data type in JavaScript, which can be divided into three main categories:
- Primitive data types
- Composite data types
- Special data types
Primitive data types:
~String, Number, Boolean.
Composite data types:
~Object, Array, Function.
Special data types:
~Undefined and null.
What is the use of isNaN function?
The isNaN() function checks whether a value is an illegal number that means it is checking if the value is Not-a-Number. This function returns true if the value equates to NaN. Otherwise, it returns false.
Null Vs Undefined?
In JavaScript, undefined means whether a variable is declared but no value has been assigned, on the other hand, null is an object in javaScript.
What is Scope in javaScript?
JavaScript has a function scope Each function creates a new scope. Scope determines the accessibility of these variables. Variables defined inside a function are not accessible from outside the function.