Commonly asked JavaScript Interview Questions | Set 1

23 Jul, 2019
What is JavaScript(JS)?JavaScript is a lightweight, interpreted programming language with object-oriented capabilities that allows you to build interactivity into otherwise static HTML pages.What are the features of JavaScript?JavaScript is a lightweight, interpreted programming language.JavaScript is designed for creating network-centric applications.JavaScript is complementary to and integrated with Java.JavaScript is complementary to and integrated with HTML.JavaScript is open and cross-platform.What are the advantages of JavaScript?Less server interaction? You can validate user input before sending the page off to the server.Immediate feedback to the visitors? They don’t have to wait for a page reload to see if they have forgotten to enter something.Increased interactivity? You can create interfaces that react when the user hovers over them with a mouse or activates them via the keyboardWhy is javascript called Richer Interface?You can use JavaScript to include such items as drag-and-drop components and sliders to give a Rich Interface to your site visitors.Is javascript case-sensitive?Yes, JavaScript is a case-sensitive language. This means that language keywords, variables, function names, and any other identifiers must always be typed with a consistent capitalization of letters.How can we create an object in JS?var object = 
        { 
         name: "obj",
         age: 10
         };How can we read the properties of an object in js?Can write and read properties of an object using the dot(.) notation.How to create an array in js and how to read array elements?Can you define arrays using the array literal as follows?var x = [];var y = [1, 2, 3, 4, 5];An array has a length property that is useful for iteration. Can we read elements of an array as follows?for (var i = 0; i < x.length; i++)How many types of functions JS support?A function in JavaScript can be either named or anonymous.How to define an anonymous function?An anonymous function can be defined in a similar way as a normal function but it would not have any name.Which built-in method calls a function for each element in the array?forEach method calls a function for each element in the array.Which type of variable among global and local, takes precedence over other if names are same?A local variable takes precedence over a global variable with the same name.Difference between “var” and “let” Keywords?Var was there from the beginning but the let was introduced in ES2015/ES6.Let has block scope and “Var” has function scopeDifference between “==” and “===” ?” ==” only compares values “===” compare values and type both.Difference between “undefine” and “NULL” Keywords?When you define a var but not assign any value. typeof(undefine)=> undefineNull- manually done. typeof(null)=> objectWhat is prototypal Inheritance?Every object has a property called a prototype, where we can add methods to it and when you create another object from these the newly created object will automatically inherit its parent’s property.Which built-in method sorts the elements of an array?Sort method sorts the elements of an array.Which built-in method reverses the order of the elements of an array?Reverse method reverses the order of the elements of an array ?? the first becomes the last, and the last becomes the first.What is SetTimeout()?When you setTimeout it becomes asynchronous and it has to wait on the stack to get everything got finishedHow to add one new element at end of an array in javascript?Push method adds one or more elements to the end of an array and returns the new length of the array.What is closure and how do you use it?When a function returns the other function the returning function will hold its environment and this is known as closure.Output of below statements<script>document.write({});</script>How can you move element in lowercase to uppercase from an array?toUpperCase method returns the calling string value converted to upper case.
What is JavaScript(JS)?JavaScript is a lightweight, interpreted programming language with object-oriented capabilities that allows you to build interactivity into otherwise static HTML pages.
JavaScript is a lightweight, interpreted programming language with object-oriented capabilities that allows you to build interactivity into otherwise static HTML pages.
What are the features of JavaScript?JavaScript is a lightweight, interpreted programming language.JavaScript is designed for creating network-centric applications.JavaScript is complementary to and integrated with Java.JavaScript is complementary to and integrated with HTML.JavaScript is open and cross-platform.
JavaScript is a lightweight, interpreted programming language.
JavaScript is designed for creating network-centric applications.
JavaScript is complementary to and integrated with Java.
JavaScript is complementary to and integrated with HTML.
JavaScript is open and cross-platform.
What are the advantages of JavaScript?Less server interaction? You can validate user input before sending the page off to the server.Immediate feedback to the visitors? They don’t have to wait for a page reload to see if they have forgotten to enter something.Increased interactivity? You can create interfaces that react when the user hovers over them with a mouse or activates them via the keyboard
Less server interaction? You can validate user input before sending the page off to the server.
Immediate feedback to the visitors? They don’t have to wait for a page reload to see if they have forgotten to enter something.
Increased interactivity? You can create interfaces that react when the user hovers over them with a mouse or activates them via the keyboard
Why is javascript called Richer Interface?You can use JavaScript to include such items as drag-and-drop components and sliders to give a Rich Interface to your site visitors.
You can use JavaScript to include such items as drag-and-drop components and sliders to give a Rich Interface to your site visitors.
Is javascript case-sensitive?Yes, JavaScript is a case-sensitive language. This means that language keywords, variables, function names, and any other identifiers must always be typed with a consistent capitalization of letters.
Yes, JavaScript is a case-sensitive language. This means that language keywords, variables, function names, and any other identifiers must always be typed with a consistent capitalization of letters.
How can we create an object in JS?var object = 
        { 
         name: "obj",
         age: 10
         };
var object = 
        { 
         name: "obj",
         age: 10
         };
How can we read the properties of an object in js?Can write and read properties of an object using the dot(.) notation.
Can write and read properties of an object using the dot(.) notation.
How to create an array in js and how to read array elements?Can you define arrays using the array literal as follows?var x = [];var y = [1, 2, 3, 4, 5];An array has a length property that is useful for iteration. Can we read elements of an array as follows?for (var i = 0; i < x.length; i++)
var x = [];
var y = [1, 2, 3, 4, 5];
An array has a length property that is useful for iteration. Can we read elements of an array as follows?
for (var i = 0; i < x.length; i++)
How many types of functions JS support?A function in JavaScript can be either named or anonymous.
A function in JavaScript can be either named or anonymous.
How to define an anonymous function?An anonymous function can be defined in a similar way as a normal function but it would not have any name.
An anonymous function can be defined in a similar way as a normal function but it would not have any name.
Which built-in method calls a function for each element in the array?forEach method calls a function for each element in the array.
forEach method calls a function for each element in the array.
Which type of variable among global and local, takes precedence over other if names are same?A local variable takes precedence over a global variable with the same name.
A local variable takes precedence over a global variable with the same name.
Difference between “var” and “let” Keywords?Var was there from the beginning but the let was introduced in ES2015/ES6.Let has block scope and “Var” has function scope
Var was there from the beginning but the let was introduced in ES2015/ES6.Let has block scope and “Var” has function scope
Difference between “==” and “===” ?” ==” only compares values “===” compare values and type both.
” ==” only compares values “===” compare values and type both.
Difference between “undefine” and “NULL” Keywords?When you define a var but not assign any value. typeof(undefine)=> undefineNull- manually done. typeof(null)=> object
When you define a var but not assign any value. typeof(undefine)=> undefineNull- manually done. typeof(null)=> object
What is prototypal Inheritance?Every object has a property called a prototype, where we can add methods to it and when you create another object from these the newly created object will automatically inherit its parent’s property.
Every object has a property called a prototype, where we can add methods to it and when you create another object from these the newly created object will automatically inherit its parent’s property.
Which built-in method sorts the elements of an array?Sort method sorts the elements of an array.
Sort method sorts the elements of an array.
Which built-in method reverses the order of the elements of an array?Reverse method reverses the order of the elements of an array ?? the first becomes the last, and the last becomes the first.
Reverse method reverses the order of the elements of an array ?? the first becomes the last, and the last becomes the first.
What is SetTimeout()?When you setTimeout it becomes asynchronous and it has to wait on the stack to get everything got finished
When you setTimeout it becomes asynchronous and it has to wait on the stack to get everything got finished
How to add one new element at end of an array in javascript?Push method adds one or more elements to the end of an array and returns the new length of the array.
Push method adds one or more elements to the end of an array and returns the new length of the array.
What is closure and how do you use it?When a function returns the other function the returning function will hold its environment and this is known as closure.
When a function returns the other function the returning function will hold its environment and this is known as closure.
Output of below statements<script>document.write({});</script>
<script>document.write({});</script>
How can you move element in lowercase to uppercase from an array?toUpperCase method returns the calling string value converted to upper case.
toUpperCase method returns the calling string value converted to upper case.
Ansari786
interview-preparation
Picked
JavaScript
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.