Open In App

Commonly asked JavaScript Interview Questions | Set 1

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Share
Report issue
Report

  1. 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.

  2. 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.

  3. 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

  4. 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.

  5. 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.

  6. How can we create an object in JS?
    var object = 
            { 
             name: "obj",
             age: 10
             };

  7. How can we read the properties of an object in js?
    • Can write and read properties of an object using the dot(.) notation.

  8. 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++)

  9. How many types of functions JS support?
    • A function in JavaScript can be either named or anonymous.

  10. 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.

  11. Which built-in method calls a function for each element in the array?
    • forEach method calls a function for each element in the array.

  12. 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.

  13. 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

  14. Difference between “==” and “===” ?
    • ” ==” only compares values “===” compare values and type both.

  15. Difference between “undefine” and “NULL” Keywords?
    • When you define a var but not assign any value. typeof(undefine)=> undefine
      Null- manually done. typeof(null)=> object

  16. 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.

  17. Which built-in method sorts the elements of an array?
    • Sort method sorts the elements of an array.

  18. 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.

  19. What is SetTimeout()?
    • When you setTimeout it becomes asynchronous and it has to wait on the stack to get everything got finished

  20. 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.

  21. 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.

  22. Output of below statements




    <script>
    document.write({});
    </script>

    
    


  23. How can you move element in lowercase to uppercase from an array?
    • toUpperCase method returns the calling string value converted to upper case.

Last Updated : 23 Jul, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads