In this article we are going to cover JavaScript interview questions 

So you might be aware that javascript is a scripting language that is used to create and control dynamic website content that is anything that moves refreshes or otherwise changes on your screen without requiring you to manually reload a web page.

let's start with a question 

1. how properties are assigned to an object ?

Ans: There are different ways we can use square bracket as well as dot operator to assign any property to a object.

2. What is the difference between ==  and === ?

Ans: Double it will do checks only for the Equality in values whereas triple equal to checks either the value or the type of the two variables are equal or not.

3. Explain how to detect the operating system on the client machine.

Ans: We can use navigator.platform property to check the operating system on the machine 

4. What is the function of delete operator ?

Ans: Delete is used to delete the property as well as the value for example we have an object named student in which we have two properties these are age and badge if you are writing delete student.age this will delete its property and its value that is 20 from the object student.

5. What is the use of void(0) ?

Ans: void(0) is used to prevent the page from refreshing and parameter 0 is passed while calling so it is also used to call another method without refreshing the page

6
. what is the way to get the status of a check box ?

Ans: If the check box will be checked this alert will return true so here in the alert we have checked whether this id has jade attribute or not.

7. What is the difference between an alert box and a confirmation box ? 

Ans: An alert box displays only one button which is the okay button but a confirmation box displays two buttons that is okay as well as cancel. 

8. What are javascript cookies ?

Ans: Cookies are the small text files stored in a computer and it gets created when the user which visits any website stood to store information that they need example it could be user name details and shopping card information from the previous Wizards.

 9. What is th use of push method in JavaScript ?

Ans:  Push method is used to add or append one or more elements to the end of an array but with this method we can append multiple elements by passing multiple arguments.

10. What is unshipped method in javascript ? 

Ans: Unshipped method is like push method which works at the beginning of the array this method is used to prepare one or more elements to the beginning of the array.

11. Explained window.onload and on document ready.

Ans: All node function is not run until all the information on the page is loaded this leads to a substantial delay before any code is executed whereas on document loads the cord just after the Dom us ready this allows early manipulation of the code  

12. Define event bubbling ? 

Ans: JavaScript allows Dom elements to be nested inside each other in such case if the handler of the child is clicked the handler of parent will also work as if it were clicked - so this whole whole effect is called event bubbling.

13. What is the use of history object ?

Ans: The history object of a browser can be used to switch to history pages such as back and forward.from the current page so there are three methods which are history.back history.forward and history.go in which we pass the number and here number can be for what it is can be positive for forward it can be negative for backward.

14.  What is a difference between undefined value and null value ? 

Ans: Undefined value is a value that is not defined and has no keyword and null value that is explicitly specified by the keyboard null here we have given two examples in first example we have used int that number which is of integer type and this in a number and in this the number has undefined value where if you look at the another example that is strength STR is equal to null hair STR string has a null value. 

15. What is JavaScript strict mode ? 

Ans: Strict mode is a restricted variant of JavaScript usually this language is not very strict in Turing errors but if we write strict mode it will throw errors of all the types even they are silent errors thus the process of debugging becomes easier and the chances of making mistake in the code is also reduced so this is a very important

16. What are self invoking functions ? 

Ans: These are known as immediately invoked function expressions these are also called as self executing anonymous function and we have a term that is iffy if we talk about the full form of the FE it is only immediately invoked function expression so these functions are involved automatically in the code so therefore that is known as self invoking functions.

17. Why javascript is called as a loosely typed or dynamic language ?

Ans: Javascript is called as a loosely type or a dynamic language because JavaScript variables are not directly associated with any value type and any variable can be assigned or reassigned value of all the types for example firstly we have a variable that is my bar which is strained and then we are reassigning it to boolean and then again reassigning it to a number.

18. What is closure and is a very important ? 

Ans: The closure is a primary mechanism to private the data items closures give access to the outer function scope from inner function scope closures are created for every function in JavaScript so in order to define the closure create a function inside another function to expose it

19. Explain the terms synchronous and asynchronous code ? 

Ans: The synchronous code is something that should be finished before anything else can happen or in other words the synchronous code is blocking and the our synchronous code is something in which actions can happen and is not dependent on another actions so in other words a synchronous code are non blocking

20. Explained the term array slice method and array splice method ? 

Ans: Any slice method removes the array items from the array and reforms the removed item into a new array and array splice method removes the items of the selected array from the array and does not form another error.

21. can redirection of a page is possible in JavaScript ?

Ans: Redirection of page is possible by using the two ways these are location.href and location.replace

22. How to remove and add properties from object ? 

Ans: By using object dot property name equal to value we can add a property to the JavaScript object whereas by using delete object or property name it is used to remove the property from the JavaScript object we have already studied the delete problem of delete method to delete the property from an object.

23. What is the difference between type of and instance of operators in JavaScript ?

Ans: Type of operator returns a string of word the type the operand is whereas instance of operator does not work with primitive data types but works with objects and checks on what type the object is a 

24. Named some of the JavaScript frameworks ? 

Ans: We have various frameworks but popular one are angular and view and if we talk about the react.js it is not a framework it is a JavaScript library .

25. What are anonymous functions in JavaScript ? 

Ans: Anonymous function allows our developer to create a function that has no name in in other words these functions can be used to store a bit of functionality in a variable and pass that piece of functionality around this is the syntax of the anonymous function.

26. What is Dom ? 

Ans: Dom stands for document object model it is an object-oriented representation of the HTML all the elements or nodes are part of window dot document so if we inspect using the f12 of n into any browser or we can say into Chrome then we can see the dawn of the complete web page.

27. What is a difference between window and document in JavaScript  ?

Ans: JavaScript window is a global object which holds variables functions history location whereas the document also come under window and can be considered as the property of the window. 

28. What is the difference between inner HTML and inner text ? 

Ans: inner HTML will process an HTML found tag I found in a string whereas inner text will not look at this example we are using document dot query selector of p tag where we are assigning dot inner HTML to one br tag then two which gives the output one and two in two different lines because because we are using a break tag but if we write the complete statement using dot inner text then this will going to display this the complete statement that is one br tag 2 as the output.

29. What is the difference between html collection and node list ?

Ans: the function query selector all returns node list in which for each can be used directly to traverse that elements whereas get element by class name or tag name returns an HTML collection which does not have a for each by default.

Thank you !