2. How to tell if a variable is global or local ?
3. Does the value of Global variable is retained if the web page is reloaded ?
Ans. Using var keyword
7. Is variable defined with let keyword can be redeclared ?
Ans. Number function
9. What is the difference between undefined and NaN ?
Ans. A variable is “undefined” if it has been created but it has not been assigned a value yet. The value NaN (not a number) is used to represent a situation when a calculation did not create a numeric result.
Ans. There are three methods which can be used to extract a part of a String:-
11. What is the difference between substring() and slice() method ?
Ans. slice() accepts negative indexes where as substring() does not accept negative indexes.
12. Which method can be used to remove whitespace from both sides of a string ?
Ans. trim() method
13. How to find the size of an array ?
Ans. By using length property of array variable.
14. Does array always store similar kind of objects ?
Ans. No. An array can have multiple types of objects like numbers, strings and references to other objects.
15. What happen to the indexes of an array where value is not assigned ?
Ans. It will be set to undefined
Ans. this keyword refers to an object which is executing the current set of code.
Ans. V8 Engine
Ans. delete is an unary operator which is used to delete the object property or array element specified as its operand.
Ans. throw expression
26. Can we use the with statement in strict mode ?
Ans. No, with statement is not allowed in strict mode.
27. What is Object Serialization ?
Ans. It is the process of converting an object’s state to a string from which it can later be restored.
Ans. JSON.stringify() and JSON.parse()
29. What is the difference between valueOf() and toString() method ?
Ans. By calling the Symbol() factory function
31. Can you add a new property to an existing object constructor ?
33. What is NodeList object ?
Ans. It is a collection of nodes extracted from a document.
34. Is NodeList an Array ?
Ans. No, NodeList looks very similar to an array but none of the array methods work on NodeList.
35. What is Destructuring ?
36. What are Arrow Functions ?
Ans. Arrow Functions provides an alternative way to write functions expressions.
Ans. There are three methods which can be used to convert variables to numbers:-
- Number() method
- parseInt() method
- parseFloat() method
38. Which method can be used to sort an array alphabetically ?
39. Which method can be used to reverse the elements in an array ?
40. Which array method can be used to make a shallow copy of a portion of an existing array ?
Ans. Array.slice() method
41. Which array method can be used to check whether the passed variable is an array object ?
Ans. Array.isArray() method
42. Which array method can be used to find all the items in an array that match a certain condition ?
Ans. Array.filter() method
43. What is the easiest to remove all the elements from an array ?
Ans. Set the length property of that array to 0.
44. What is the easiest way to remove all the duplicates from an array ?
Ans. Create a new Set object and fill it with your array.
45. Which array method can be used to flatten a two dimensional array to a one-dimensional list ?
Ans. Array.flat() method
46. Which of the popular array methods can be used to search an array for a specific value ?
Ans. There are mainly three array searching methods that can be used:-
47. Which array method can be used to search an object in an array ?
Ans. By Replacing function with function*
Ans. The technique of wrapping one function in another function to lock down one or more argument values is called partial application.
50. Which method can be used to freeze an object properties against any changes ?