Google News
logo
JavaScript Interview Questions
JavaScript is the programming language of the Web. Javascript Most commonly used websites this is client-side script to interact with the user and make dynamic pages. All modern web browsers on desktops, tablets, and smart phones are using JavaScript.
The first JavaScript engine was created by Brendan Eich at Netscape, for the Netscape Navigator Web browser. The engine, code-named SpiderMonkey, is implemented in C. It has since been updated (in JavaScript 1.5) to conform to ECMAScript 3.
To create function in JavaScript, follow the following syntax :

<script type="text/javascript">
   function function_name(){
     //function body
   }
</script>
JavaScript uses reserved keyword var to declare a variable. A variable must have a unique name. You can assign a value to a variable using equal to (=) operator when you declare it or before using it.

There are two types of variables in JavaScript  :
 
1. local variables  : A variable that is declared inside of a function definition is called local variable and has scope to that function only. 
2.global variables :  A variable that is declared outside of a function definition is called a global variable and its scope is throughout your program means its value is accessible and modifiable throughout your program.

Basic Syntax :
var <variable-name>;
var <variable-name> = <value>;
JavaScript operators are used to assign values, compare values, arithmetic operations, and more. For example 1 + 2, where + sign is an operator and 1 is left operand and 2 is right operand. + operator adds two numeric values and produces a result which is 3 in this case.

1. Arithmetic Operators
2. Comparison Operators
3. Logical Operators
4. Bitwise Operators
5. Assignment  Operators
Following are the JavaScript Data types :

1. Primitive data type
2. Non-primitive (reference) data type

JavaScript has dynamic types. This means that the same variable can be used to hold different data types :
var x;     // Now x is undefined
var x = 10;     // Now x is a Number
var x = "Name";     // Now x is a String

Primitive data types : There are six types of primitive data types in JavaScript. They are as follows :
Number
String
Boolean
Null
Symbol
Undefined

Non-Primitive data types : The non-primitive data types are as follows :
Object
Array
RegExp
A prompt box is a box which allows the user to enter input by providing a text box.  Label and box will be provided to enter the text or number.
‘this’ keyword refers to the object from where it was called.
The == operator checks equality only whereas === checks equality and data type i.e. value must be of same type.
The functionality of delete operator is used to delete all variables and objects in a program but it cannot delete variables declared with VAR keyword.