I am assuming that js file name is samplefile.js, place the following script tag inside the head tag.
6) What is BOM?
BOM stands for Browser Object Model. It provides interaction with the browser. The default object of browser is window. Browser Object Model
7) What is DOM? What is the use of document object?
DOM stands for Document Object Model. A document object represents the html document. It can be accustomed to access and change the content of html of Document Object Model
8) What is the use of window object?
The window object is automatically created by the browser that represents a window of a browser.
It is used to show the popup dialog box such as alert confirm dialog box, dialog box, input dialog box etc.
9) What is the use of history object?
The history object of browser is accustomed switch to history pages like back and forward from current page or another page. There are three methods of history object.
history.go(number): number may be positive for forward, negative for backward.
Single Line Comment: It is written as // (double forward slash)
Multi Line Comment: It is written as slash with asterisk symbol as /* write comment here */
- Primitive Data Types
- Non-primitive Data Types
13) What is the difference between == and ===?
The == operator checks equality only whereas === checks equality and data type i.e. value must be of same type(strict in nature).
- By object literal
- By creating instance of Object
- By Object Constructor
Let’s see an easy code to create object using object literal.
- By array literal
- By creating instance of Array
- By using an Array constructor
Let’s see an easy code to create array using object literal.
18) What does the isNaN() function?
The isNan() function returns true if the variable or given value is not a number.
3030 because 10+20 will be 30. If there is numeric value before and after +, it is treated is binary + and inside double codes it is treated as string value (arithmetic operator).
Output is 102030 because after a string all the + will be treated as string concatenation operator (not binary +).
22) In which location cookies are stored on the hard disk?
The storage of cookies on the hard disk depends on OS and also the browser.
The Netscape navigator on Windows uses samplecookies.txt file that contains all the cookies. The path is : c:\Program Files\Netscape\Users\Username\samplecookies.txt
The Internet Explorer stores the cookies on a file email@example.com. The path is: c:\Windows\Cookies\[email protected].
24) What is the difference between undefined value and null value?
- Undefined value is the value that is not defined and has no keyword is known as undefined value. For Example:
int number;//Here, number has undefined value.
- Null value is the value that is explicitly specified by the keyword “null” is known as null value. For Example:
String str=null;//Here, str has a null value.
window.document.body.style.cursor = “wait”;
25) What is this?
var myArray = [[]];
Three dimensional array.
27) What is negative infinity?
28) What is difference between View state and Session state?
“View state” is restricted to a page in a session whereas “Session state” is specific to a user or browser which will be accessed across all pages in the web application.
- Alert Box
- Confirm Box
- Prompt Box
The navigator.appVersion string can be used to detect the operating system on the client machine.
<form name=”myform” action=”index.php”>
Search: <input type=’text’ name=’query’ />
Yes, as a result of it doesn’t require web server’s support for execution.