21.  

What are the different types of errors in JavaScript?

There are three types of errors:

  •     Load time errors: Errors which come up when loading a web page like improper syntax errors are known as Load time errors and it generates the errors dynamically.
  •     Run time errors: Errors that come due to misuse of the command inside the HTML language.
  •     Logical Errors: These are the errors that occur due to the bad logic performed on a function which is having different operation.
     
22.  

Explain window.onload and onDocumentReady?

  • The onload function is not run until all the information on the page is loaded. This leads to a substantial delay before any code is executed.
  •  onDocumentReady loads the code just after the DOM is loaded. This allows early manipulation of the code.
23.  

What is the difference between .call() and .apply()?
 

 

  • The function .call() and .apply() are very similar in their usage except a little difference. .call() is used when the number of the function’s arguments are known to the programmer, as they have to be mentioned as arguments in the call statement. On the other hand, .apply() is used when the number is not known. The function .apply() expects the argument to be an array.
  •  The basic difference between .call() and .apply() is in the way arguments are passed to the function. Their usage can be illustrated by the given example
     
Example:


var someObject = {
 
myProperty : 'Foo',
 
myMethod : function(prefix, postfix) {
 
alert(prefix + this.myProperty + postfix);
 
}
 
};
 
someObject.myMethod('<', '>'); // alerts '<Foo>'
 
var someOtherObject  = {
 
myProperty : 'Bar'
 
};
 
someObject.myMethod.call(someOtherObject, '<', '>'); // alerts '<Bar>'
 
someObject.myMethod.apply(someOtherObject, ['<', '>']); // alerts '<Bar>

24.  

What boolean operators can be used in JavaScript?
 

The ‘And’ Operator (&&), ‘Or’  Operator (||) and the ‘Not’ Operator (!) can be used in JavaScript.

*Operators are without the parenthesis.

25.  

How are DOM utilized in JavaScript?
 

DOM stands for Document Object Model and is responsible for how various objects in a document interact with each other. DOM is required for developing web pages, which includes objects like paragraph, links, etc. These objects can be operated to include actions like add or delete. DOM is also required to add extra capabilities to a web page. On top of that, the use of API gives an advantage over other existing models.