Ans: I am assuming that js file name is message.js, place the following script tag inside the head tag.
6Q) What is BOM?
Ans: BOM stands for Browser Object Model. It provides interaction with the browser. The default object of the browser is the window.
7Q) What is DOM? What is the use of document object?
Ans: DOM stands for Document Object Model. A document object represents the HTML document. It can be used to access and change the content of HTML.
8Q) What is the use of window object?
Ans: The window object is automatically created by the browser that represents a window of a browser.
It is used to display the popup dialog box such as the alert dialog box, confirm dialog box, input dialog box, etc.
9Q) What is the use of history objects?
Ans: The history object of the browser can be used to switch to history pages such as back and forward from the 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 represented by // (double forward slash)
Multi-Line Comment: It is represented by a slash with asterisk symbol as /* write comment here */
Primitive Data Types
Non-primitive Data Types
13Q) What is the difference between == and ===?
Ans: The == operator checks equality only whereas === checks equality and data type i.e. value must be of the same type.
By object literal
By creating an instance of Object
By Object Constructor
Let's see a simple code to create an object using an object literal.
By array literal
By creating an instance of Array
By using an Array constructor
Let's see a simple code to create an array using object literal.
18Q) What does the isNaN() function?
Ans: The isNan() function returns true if the variable value is not a number.
Ans: 3030 because 10+20 will be 30. If there is a numeric value before and after +, it is treated is binary + (arithmetic operator).
Ans: 102030 because after a string all the + will be treated as a string concatenation operator (not binary +).
22Q) In which location cookies are stored on the hard disk?
Ans: The storage of cookies on the hard disk depends on OS and the browser.
The Internet Explorer stores the cookies on a file email@example.com. The path is: c:WindowsCookiesusername@Website.txt.
24Q) What is the difference between undefined value and null value?
Ans: Undefined value: A value that is not defined and has no keyword is known as an undefined value. For example:
int number;//Here, the number has an undefined value.
Null value: A 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";
26Q) What is this?
Ans: var myArray = [[]];
28Q) What is negative infinity?
29Q) What is the difference between View state and Session state?
Ans: "View state" is specific to a page in a session whereas "Session state" is specific to a user or browser that can be accessed across all pages in the web application.
Ans: Alert Box
Ans: 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, because it doesn't require a web server's support for execution.