document.write(“Welcome to Hello World!”);
I am assuming that js file name is externalfile.js, place the following script tag inside the head tag.
Primary Data Types
Composite Data Types
Special Data Types
Undefined value means the:
• Variable used in the code doesn’t exist
• Variable is not assigned to any value
• Property doesn’t exist
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 errors that occur due to the wrong logic performed on a function.
9) 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
10) 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
11) 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.
12) 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
16) 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.
21) 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 +).
25) 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 locationcookies.txt file that contains all the cookies. The path is : c:\Program Files\Netscape\Users\Username\locationcookies.txt
The Internet Explorer stores the cookies on a file email@example.com. The path is: c:\Windows\Cookies\uname@Website.txt.
27) 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”;
29) What is this?
In a method, this refers to the owner object.
Alone, this refers to the global object.
In a function, this refers to the global object.
In a function, in strict mode, this is undefined.
In an event, this refers to the element that received the event.
Methods like call(), and apply() can refer this to any object.
31) What is negative infinity?
32) 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.
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.