JavaScript and Ajax Interview questions
1. Why so JavaScript and Java have similar name?
A. JavaScript is a stripped-down version of Java
B. JavaScript’s syntax is loosely based on Java’s
C. They both originated on the island of Java
D. None of the above
2. When a user views a page containing a JavaScript program, which machine actually executes the script?
A. The User’s machine running a Web browser
B. The Web server
C. A central machine deep within Netscape’s corporate offices
D. None of the above
3. ______ JavaScript is also called client-side JavaScript.
A. Microsoft
B. Navigator
C. LiveWire
D. Native
4. __________ JavaScript is also called server-side JavaScript.
A. Microsoft
B. Navigator
C. LiveWire
D. Native
5. What are variables used for in JavaScript Programs?
A. Storing numbers, dates, or other values
B. Varying randomly
C. Causing high-school algebra flashbacks
D. None of the above
6. _____ JavaScript statements embedded in an HTML page can respond to user events such as mouse-clicks, form input, and page navigation.
A. Client-side
B. Server-side
C. Local
D. Native
7. What should appear at the very end of your JavaScript?
The <script LANGUAGE=”JavaScript”>tag
A. The </script>
B. The <script>
C. The END statement
D. None of the above
8. Which of the following can’t be done with client-side JavaScript?
A. Validating a form
B. Sending a form’s contents by email
C. Storing the form’s contents to a database file on the server
D. None of the above
9. Which of the following are capabilities of functions in JavaScript?
A. Return a value
B. Accept parameters and Return a value
C. Accept parameters
D. None of the above
10. Which of the following is not a valid JavaScript variable name?
A. 2names
B. _first_and_last_names
C. FirstAndLast
D. None of the above
11. ______ tag is an extension to HTML that can enclose any number of JavaScript statements.
A. <SCRIPT>
B. <BODY>
C. <HEAD>
D. <TITLE>
12. How does JavaScript store dates in a date object?
A. The number of milliseconds since January 1st, 1970
B. The number of days since January 1st, 1900
C. The number of seconds since Netscape’s public stock offering.
D. None of the above
13. Which of the following attribute can hold the JavaScript version?
A. LANGUAGE
B. SCRIPT
C. VERSION
D. None of the above
14. What is the correct JavaScript syntax to write “Hello World”?
A. System.out.println(“Hello World”)
B. println (“Hello World”)
C. document.write(“Hello World”)
D. response.write(“Hello World”)
15. Which of the following way can be used to indicate the LANGUAGE attribute?
A. <LANGUAGE=”JavaScriptVersion”>
B. <SCRIPT LANGUAGE=”JavaScriptVersion”>
C. <SCRIPT LANGUAGE=”JavaScriptVersion”> JavaScript statements…</SCRIPT>
D. <SCRIPT LANGUAGE=”JavaScriptVersion”!> JavaScript statements…</SCRIPT>
16. Inside which HTML element do we put the JavaScript?
A. <js>
B. <scripting>
C. <script>
D. <javascript>
17. What is the correct syntax for referring to an external script called ” abc.js”?
A. <script href=”http://9.cdn.blog.com/wp-admin/ abc.js”>
B. <script name=” abc.js”>
C. <script src=”http://9.cdn.blog.com/wp-admin/ abc.js”>
D. None of the above
18. Which types of image maps can be used with JavaScript?
A. Server-side image maps
B. Client-side image maps
C. Server-side image maps and Client-side image maps
D. None of the above
19. Which of the following navigator object properties is the same in both Netscape and IE?
A. navigator.appCodeName
B. navigator.appName
C. navigator.appVersion
D. None of the above
20. Which is the correct way to write a JavaScript array?
A. var txt = new Array(1:”tim”,2:”kim”,3:”jim”)
B. var txt = new Array:1=(“tim”)2=(“kim”)3=(“jim”)
C. var txt = new Array(“tim”,”kim”,”jim”)
D. var txt = new Array=”tim”,”kim”,”jim”
21. What does the <noscript> tag do?
A. Enclose text to be displayed by non-JavaScript browsers.
B. Prevents scripts on the page from executing.
C. Describes certain low-budget movies.
D. None of the above
22. If para1 is the DOM object for a paragraph, what is the correct syntax to change the text within the paragraph?
A. “New Text”?
B. para1.value=”New Text”;
C. para1.firstChild.nodeValue= “New Text”;
D. para1.nodeValue=”New Text”;
23. JavaScript entities start with _______ and end with _________.
A. Semicolon, colon
B. Semicolon, Ampersand
C. Ampersand, colon
D. Ampersand, semicolon
24. Which of the following best describes JavaScript?
A. a low-level programming language.
B. a scripting language precompiled in the browser.
C. a compiled scripting language.
D. an object-oriented scripting language.
25. Choose the server-side JavaScript object?
A. FileUpLoad
B. Function
C. File
D. Date
26. Choose the client-side JavaScript object?
A. Database
B. Cursor
C. Client
D. FileUpLoad
27. Which of the following is not considered a JavaScript operator?
A. new
B. this
C. delete
D. typeof
28. ______method evaluates a string of JavaScript code in the context of the specified object.
A. Eval
B. ParseInt
C. ParseFloat
D. Efloat
29. Which of the following event fires when the form element loses the focus: <button>, <input>, <label>, <select>, <textarea>?
A. onfocus
B. onblur
C. onclick
D. ondblclick
30. The syntax of Eval is ________________
A. [objectName.]eval(numeric)
B. [objectName.]eval(string)
C. [EvalName.]eval(string)
D. [EvalName.]eval(numeric)
31. JavaScript is interpreted by _________
A. Client
B. Server
C. Object
D. None of the above
32. Using _______ statement is how you test for a specific condition.
A. Select
B. If
C. Switch
D. For
33. Which of the following is the structure of an if statement?
A. if (conditional expression is true) thenexecute this codeend if
B. if (conditional expression is true)execute this codeend if
C. if (conditional expression is true) {then execute this code>->}
D. if (conditional expression is true) then {execute this code}
34. How to create a Date object in JavaScript?
A. dateObjectName = new Date([parameters])
B. dateObjectName.new Date([parameters])
C. dateObjectName := new Date([parameters])
D. dateObjectName Date([parameters])
35. The _______ method of an Array object adds and/or removes elements from an array.
A. Reverse
B. Shift
C. Slice
D. Splice
36. To set up the window to capture all Click events, we use which of the following statement?
A. window.captureEvents(Event.CLICK);
B. window.handleEvents (Event.CLICK);
C. window.routeEvents(Event.CLICK );
D. window.raiseEvents(Event.CLICK );
37. Which tag(s) can handle mouse events in Netscape?
A. <IMG>
B. <A>
C. <BR>
D. None of the above
38. ____________ is the tainted property of a window object.
A. Pathname
B. Protocol
C. Defaultstatus
D. Host
39. To enable data tainting, the end user sets the _________ environment variable.
A. ENABLE_TAINT
B. MS_ENABLE_TAINT
C. NS_ENABLE_TAINT
D. ENABLE_TAINT_NS
40. In JavaScript, _________ is an object of the target language data type that encloses an object of the source language.
A. a wrapper
B. a link
C. a cursor
D. a form
41. When a JavaScript object is sent to Java, the runtime engine creates a Java wrapper of type ___________
A. ScriptObject
B. JSObject
C. JavaObject
D. Jobject
42. _______ class provides an interface for invoking JavaScript methods and examining JavaScript properties.
A. ScriptObject
B. JSObject
C. JavaObject
D. Jobject
43. _________ is a wrapped Java array, accessed from within JavaScript code.
A. JavaArray
B. JavaClass
C. JavaObject
D. JavaPackage
44. A ________ object is a reference to one of the classes in a Java package, such as netscape.javascript .
A. JavaArray
B. JavaClass
C. JavaObject
D. JavaPackage
45. The JavaScript exception is available to the Java code as an instance of __________
A. netscape.javascript.JSObject
B. netscape.javascript.JSException
C. netscape.plugin.JSException
D. None of the above
46. To automatically open the console when a JavaScript error occurs which of the following is added to prefs.js?
A. user_pref(” javascript.console.open_on_error”, false);
B. user_pref(“javascript.console.open_error “, true);
C. user_pref(“javascript.console.open_error “, false);
D. user_pref(“javascript.console.open_on_error”, true);
47. To open a dialog box each time an error occurs, which of the following is added to prefs.js?
A. user_pref(“javascript.classic.error_alerts”, true);
B. user_pref(“javascript.classic.error_alerts “, false);
C. user_pref(“javascript.console.open_on_error “, true);
D. user_pref(“javascript.console.open_on_error “, false);
48. The syntax of a blur method in a button object is ______________
A. Blur()
B. Blur(contrast)
C. Blur(value)
D. Blur(depth)
49. The syntax of capture events method for document object is ______________
A. captureEvents()
B. captureEvents(args eventType)
C. captureEvents(eventType)
D. captureEvents(eventVal)
50. The syntax of close method for document object is ______________
A. Close(doc)
B. Close(object)
C. Close(val)
D. Close()
_________________________________________________________________________________________
Javascript Interview Questions
1. What is JavaScript?
Java Script is a platform-independent,event-driven, interpreted client-side scripting and
programming language developed by Netscape Communications Corp. and Sun Microsystems.
2.How to read and write a file using javascript?
I/O operations like reading or writing a file is not possible with client-side javascript.
However , this can be done by coding a Java applet that reads files for the script.
3.How to detect the operating system on the client machine?
In order to detect the operating system on the client machine, the navigator.appVersion
string (property) should be used.
4.Where are cookies actually stored on the hard disk?
This depends on the user’s browser and OS.
In the case of Netscape with Windows OS,all the cookies are stored in a single file called cookies.txt
c:\Program Files\Netscape\Users\username\cookies.txt
In the case of IE,each cookie is stored in a separate file namely [email protected].
c:\Windows\Cookies\[email protected]
5.What can javascript programs do?
Generation of HTML pages on-the-fly without accessing the Web server.
The user can be given control over the browser like User input validation Simple computations can be performed on the client’s machine
The user’s browser, OS, screen size, etc. can be detected Date and Time Handling
6.How to set a HTML document’s background color?
document.bgcolor property can be set to any appropriate color.
7.What does the “Access is Denied” IE error mean?
The “Access Denied” error in any browser is due to the following reason.
A javascript in one window or frame is tries to access another window or frame whose
document’s domain is different from the document containing the script.
8.Is a javascript script faster than an ASP script?
Yes.Since javascript is a client-side script it does require the web server’s help for its
computation,so it is always faster than any server-side script like ASP,PHP,etc..
9.Are Java and JavaScript the Same?
No.java and javascript are two different languages.
Java is a powerful object – oriented programming language like C++,C whereas Javascript is a
client-side scripting language with some limitations.
10.How to embed javascript in a web page?
javascript code can be embedded in a web page between <script
langugage=”javascript”></script> tags
11.How to access an external javascript file that is stored externally and not embedded?
This can be achieved by using the following tag between head tags or between body tags.
<script src=”abc.js”></script>
where abc.js is the external javscript file to be accessed.
12.What is the difference between an alert box and a confirmation box?
An alert box displays only one button which is the OK button whereas the Confirm box
displays two buttons namely OK and cancel.
13.What is a prompt box?
A prompt box allows the user to enter input by providing a text box.
14.Can javascript code be broken in different lines?
Breaking is possible within a string statement by using a backslash \ at the end but not
within any other javascript statement.
that is ,
document.write(“Hello \world”);
is possible but not
document.write \
(“hello world”);
14.How to hide javascript code from old browsers that dont run it?
Ans.
Use the below specified style of comments
<script language=javascript>
<!–
javascript code goes here
// –>
or
Use the <NOSCRIPT>some html code </NOSCRIPT> tags and code the display html statements between these and this will appear
on the page if the browser does not support javascript
15. How to comment javascript code?
Ans.
Use // for line comments and
/*
*/ for block comments
16.Name the numeric constants representing max,min values
Ans.
Number.MAX_VALUE
Number.MIN_VALUE
17.What does javascript null mean?
Ans.
The null value is a unique value representing no value or no object.
It implies no object,or null string,no valid boolean value,no number and no array object.
18.What does undefined value mean in javascript?
Ans.
Undefined value means the variable used in the code doesnt exist or is not assigned any value or the property doesnt exist.
19.What is the difference between undefined value and null value?
Ans.
(i)Undefined value cannot be explicitly stated that is there is no keyword called undefined whereas null value has keyword called null
(ii)typeof undefined variable or property returns undefined whereas
typeof null value returns object
20.What is variable typing in javascript?
Ans.
It is perfectly legal to assign a number to a variable and then assign a string to the same variable as follows
example
i = 10;
i = “string”;
This is called variable typing
21.Does javascript have the concept level scope?
Ans.
No.Javascript does not have block level scope,all the variables declared inside a function possess the same level of scope unlike
c,c++,java.
22. What are undefined and undeclared variables?
Ans.
Undeclared variables are those that are not declared in the program (do not exist at all),trying to read their values gives runtime
error.But if undeclared variables are assigned then implicit declaration is done .
Undefined variables are those that are not assigned any value but are declared in the program.Trying to read such
varia bles gives special value called undefined value.
23. What is === operator ?
Ans.
==== is strict equality operator ,it returns true only when the two operands are having the same value without any type conversion.
24.What does the delete operator do?
Ans.
The delete operator is used to delete all the variables and objects used in the program ,but it does not delete variables declared
with var keyword.
25.What does break and continue statements do?
Ans.
Continue statement continues the current loop (if label not specified) in a new iteration whereas break statement exits the current loop.
26.How to create a function using function constructor?
Ans.
The following example illustrates this
It creates a function called square with argument x and returns x multiplied by itself.
var square = new Function (“x”,”return x*x”);
1. Why so JavaScript and Java have similar name?
A. JavaScript is a stripped-down version of Java
B. JavaScript’s syntax is loosely based on Java’s
C. They both originated on the island of Java
D. None of the above
2. When a user views a page containing a JavaScript program, which machine actually executes the script?
A. The User’s machine running a Web browser
B. The Web server
C. A central machine deep within Netscape’s corporate offices
D. None of the above
3. ______ JavaScript is also called client-side JavaScript.
A. Microsoft
B. Navigator
C. LiveWire
D. Native
4. __________ JavaScript is also called server-side JavaScript.
A. Microsoft
B. Navigator
C. LiveWire
D. Native
5. What are variables used for in JavaScript Programs?
A. Storing numbers, dates, or other values
B. Varying randomly
C. Causing high-school algebra flashbacks
D. None of the above
6. _____ JavaScript statements embedded in an HTML page can respond to user events such as mouse-clicks, form input, and page navigation.
A. Client-side
B. Server-side
C. Local
D. Native
7. What should appear at the very end of your JavaScript?
The <script LANGUAGE=”JavaScript”>tag
A. The </script>
B. The <script>
C. The END statement
D. None of the above
8. Which of the following can’t be done with client-side JavaScript?
A. Validating a form
B. Sending a form’s contents by email
C. Storing the form’s contents to a database file on the server
D. None of the above
9. Which of the following are capabilities of functions in JavaScript?
A. Return a value
B. Accept parameters and Return a value
C. Accept parameters
D. None of the above
10. Which of the following is not a valid JavaScript variable name?
A. 2names
B. _first_and_last_names
C. FirstAndLast
D. None of the above
11. ______ tag is an extension to HTML that can enclose any number of JavaScript statements.
A. <SCRIPT>
B. <BODY>
C. <HEAD>
D. <TITLE>
12. How does JavaScript store dates in a date object?
A. The number of milliseconds since January 1st, 1970
B. The number of days since January 1st, 1900
C. The number of seconds since Netscape’s public stock offering.
D. None of the above
13. Which of the following attribute can hold the JavaScript version?
A. LANGUAGE
B. SCRIPT
C. VERSION
D. None of the above
14. What is the correct JavaScript syntax to write “Hello World”?
A. System.out.println(“Hello World”)
B. println (“Hello World”)
C. document.write(“Hello World”)
D. response.write(“Hello World”)
15. Which of the following way can be used to indicate the LANGUAGE attribute?
A. <LANGUAGE=”JavaScriptVersion”>
B. <SCRIPT LANGUAGE=”JavaScriptVersion”>
C. <SCRIPT LANGUAGE=”JavaScriptVersion”> JavaScript statements…</SCRIPT>
D. <SCRIPT LANGUAGE=”JavaScriptVersion”!> JavaScript statements…</SCRIPT>
16. Inside which HTML element do we put the JavaScript?
A. <js>
B. <scripting>
C. <script>
D. <javascript>
17. What is the correct syntax for referring to an external script called ” abc.js”?
A. <script href=”http://9.cdn.blog.com/wp-admin/ abc.js”>
B. <script name=” abc.js”>
C. <script src=”http://9.cdn.blog.com/wp-admin/ abc.js”>
D. None of the above
18. Which types of image maps can be used with JavaScript?
A. Server-side image maps
B. Client-side image maps
C. Server-side image maps and Client-side image maps
D. None of the above
19. Which of the following navigator object properties is the same in both Netscape and IE?
A. navigator.appCodeName
B. navigator.appName
C. navigator.appVersion
D. None of the above
20. Which is the correct way to write a JavaScript array?
A. var txt = new Array(1:”tim”,2:”kim”,3:”jim”)
B. var txt = new Array:1=(“tim”)2=(“kim”)3=(“jim”)
C. var txt = new Array(“tim”,”kim”,”jim”)
D. var txt = new Array=”tim”,”kim”,”jim”
21. What does the <noscript> tag do?
A. Enclose text to be displayed by non-JavaScript browsers.
B. Prevents scripts on the page from executing.
C. Describes certain low-budget movies.
D. None of the above
22. If para1 is the DOM object for a paragraph, what is the correct syntax to change the text within the paragraph?
A. “New Text”?
B. para1.value=”New Text”;
C. para1.firstChild.nodeValue= “New Text”;
D. para1.nodeValue=”New Text”;
23. JavaScript entities start with _______ and end with _________.
A. Semicolon, colon
B. Semicolon, Ampersand
C. Ampersand, colon
D. Ampersand, semicolon
24. Which of the following best describes JavaScript?
A. a low-level programming language.
B. a scripting language precompiled in the browser.
C. a compiled scripting language.
D. an object-oriented scripting language.
25. Choose the server-side JavaScript object?
A. FileUpLoad
B. Function
C. File
D. Date
26. Choose the client-side JavaScript object?
A. Database
B. Cursor
C. Client
D. FileUpLoad
27. Which of the following is not considered a JavaScript operator?
A. new
B. this
C. delete
D. typeof
28. ______method evaluates a string of JavaScript code in the context of the specified object.
A. Eval
B. ParseInt
C. ParseFloat
D. Efloat
29. Which of the following event fires when the form element loses the focus: <button>, <input>, <label>, <select>, <textarea>?
A. onfocus
B. onblur
C. onclick
D. ondblclick
30. The syntax of Eval is ________________
A. [objectName.]eval(numeric)
B. [objectName.]eval(string)
C. [EvalName.]eval(string)
D. [EvalName.]eval(numeric)
31. JavaScript is interpreted by _________
A. Client
B. Server
C. Object
D. None of the above
32. Using _______ statement is how you test for a specific condition.
A. Select
B. If
C. Switch
D. For
33. Which of the following is the structure of an if statement?
A. if (conditional expression is true) thenexecute this codeend if
B. if (conditional expression is true)execute this codeend if
C. if (conditional expression is true) {then execute this code>->}
D. if (conditional expression is true) then {execute this code}
34. How to create a Date object in JavaScript?
A. dateObjectName = new Date([parameters])
B. dateObjectName.new Date([parameters])
C. dateObjectName := new Date([parameters])
D. dateObjectName Date([parameters])
35. The _______ method of an Array object adds and/or removes elements from an array.
A. Reverse
B. Shift
C. Slice
D. Splice
36. To set up the window to capture all Click events, we use which of the following statement?
A. window.captureEvents(Event.CLICK);
B. window.handleEvents (Event.CLICK);
C. window.routeEvents(Event.CLICK );
D. window.raiseEvents(Event.CLICK );
37. Which tag(s) can handle mouse events in Netscape?
A. <IMG>
B. <A>
C. <BR>
D. None of the above
38. ____________ is the tainted property of a window object.
A. Pathname
B. Protocol
C. Defaultstatus
D. Host
39. To enable data tainting, the end user sets the _________ environment variable.
A. ENABLE_TAINT
B. MS_ENABLE_TAINT
C. NS_ENABLE_TAINT
D. ENABLE_TAINT_NS
40. In JavaScript, _________ is an object of the target language data type that encloses an object of the source language.
A. a wrapper
B. a link
C. a cursor
D. a form
41. When a JavaScript object is sent to Java, the runtime engine creates a Java wrapper of type ___________
A. ScriptObject
B. JSObject
C. JavaObject
D. Jobject
42. _______ class provides an interface for invoking JavaScript methods and examining JavaScript properties.
A. ScriptObject
B. JSObject
C. JavaObject
D. Jobject
43. _________ is a wrapped Java array, accessed from within JavaScript code.
A. JavaArray
B. JavaClass
C. JavaObject
D. JavaPackage
44. A ________ object is a reference to one of the classes in a Java package, such as netscape.javascript .
A. JavaArray
B. JavaClass
C. JavaObject
D. JavaPackage
45. The JavaScript exception is available to the Java code as an instance of __________
A. netscape.javascript.JSObject
B. netscape.javascript.JSException
C. netscape.plugin.JSException
D. None of the above
46. To automatically open the console when a JavaScript error occurs which of the following is added to prefs.js?
A. user_pref(” javascript.console.open_on_error”, false);
B. user_pref(“javascript.console.open_error “, true);
C. user_pref(“javascript.console.open_error “, false);
D. user_pref(“javascript.console.open_on_error”, true);
47. To open a dialog box each time an error occurs, which of the following is added to prefs.js?
A. user_pref(“javascript.classic.error_alerts”, true);
B. user_pref(“javascript.classic.error_alerts “, false);
C. user_pref(“javascript.console.open_on_error “, true);
D. user_pref(“javascript.console.open_on_error “, false);
48. The syntax of a blur method in a button object is ______________
A. Blur()
B. Blur(contrast)
C. Blur(value)
D. Blur(depth)
49. The syntax of capture events method for document object is ______________
A. captureEvents()
B. captureEvents(args eventType)
C. captureEvents(eventType)
D. captureEvents(eventVal)
50. The syntax of close method for document object is ______________
A. Close(doc)
B. Close(object)
C. Close(val)
D. Close()
_________________________________________________________________________________________
Javascript Interview Questions
1. What is JavaScript?
Java Script is a platform-independent,event-driven, interpreted client-side scripting and
programming language developed by Netscape Communications Corp. and Sun Microsystems.
2.How to read and write a file using javascript?
I/O operations like reading or writing a file is not possible with client-side javascript.
However , this can be done by coding a Java applet that reads files for the script.
3.How to detect the operating system on the client machine?
In order to detect the operating system on the client machine, the navigator.appVersion
string (property) should be used.
4.Where are cookies actually stored on the hard disk?
This depends on the user’s browser and OS.
In the case of Netscape with Windows OS,all the cookies are stored in a single file called cookies.txt
c:\Program Files\Netscape\Users\username\cookies.txt
In the case of IE,each cookie is stored in a separate file namely [email protected].
c:\Windows\Cookies\[email protected]
5.What can javascript programs do?
Generation of HTML pages on-the-fly without accessing the Web server.
The user can be given control over the browser like User input validation Simple computations can be performed on the client’s machine
The user’s browser, OS, screen size, etc. can be detected Date and Time Handling
6.How to set a HTML document’s background color?
document.bgcolor property can be set to any appropriate color.
7.What does the “Access is Denied” IE error mean?
The “Access Denied” error in any browser is due to the following reason.
A javascript in one window or frame is tries to access another window or frame whose
document’s domain is different from the document containing the script.
8.Is a javascript script faster than an ASP script?
Yes.Since javascript is a client-side script it does require the web server’s help for its
computation,so it is always faster than any server-side script like ASP,PHP,etc..
9.Are Java and JavaScript the Same?
No.java and javascript are two different languages.
Java is a powerful object – oriented programming language like C++,C whereas Javascript is a
client-side scripting language with some limitations.
10.How to embed javascript in a web page?
javascript code can be embedded in a web page between <script
langugage=”javascript”></script> tags
11.How to access an external javascript file that is stored externally and not embedded?
This can be achieved by using the following tag between head tags or between body tags.
<script src=”abc.js”></script>
where abc.js is the external javscript file to be accessed.
12.What is the difference between an alert box and a confirmation box?
An alert box displays only one button which is the OK button whereas the Confirm box
displays two buttons namely OK and cancel.
13.What is a prompt box?
A prompt box allows the user to enter input by providing a text box.
14.Can javascript code be broken in different lines?
Breaking is possible within a string statement by using a backslash \ at the end but not
within any other javascript statement.
that is ,
document.write(“Hello \world”);
is possible but not
document.write \
(“hello world”);
14.How to hide javascript code from old browsers that dont run it?
Ans.
Use the below specified style of comments
<script language=javascript>
<!–
javascript code goes here
// –>
or
Use the <NOSCRIPT>some html code </NOSCRIPT> tags and code the display html statements between these and this will appear
on the page if the browser does not support javascript
15. How to comment javascript code?
Ans.
Use // for line comments and
/*
*/ for block comments
16.Name the numeric constants representing max,min values
Ans.
Number.MAX_VALUE
Number.MIN_VALUE
17.What does javascript null mean?
Ans.
The null value is a unique value representing no value or no object.
It implies no object,or null string,no valid boolean value,no number and no array object.
18.What does undefined value mean in javascript?
Ans.
Undefined value means the variable used in the code doesnt exist or is not assigned any value or the property doesnt exist.
19.What is the difference between undefined value and null value?
Ans.
(i)Undefined value cannot be explicitly stated that is there is no keyword called undefined whereas null value has keyword called null
(ii)typeof undefined variable or property returns undefined whereas
typeof null value returns object
20.What is variable typing in javascript?
Ans.
It is perfectly legal to assign a number to a variable and then assign a string to the same variable as follows
example
i = 10;
i = “string”;
This is called variable typing
21.Does javascript have the concept level scope?
Ans.
No.Javascript does not have block level scope,all the variables declared inside a function possess the same level of scope unlike
c,c++,java.
22. What are undefined and undeclared variables?
Ans.
Undeclared variables are those that are not declared in the program (do not exist at all),trying to read their values gives runtime
error.But if undeclared variables are assigned then implicit declaration is done .
Undefined variables are those that are not assigned any value but are declared in the program.Trying to read such
varia bles gives special value called undefined value.
23. What is === operator ?
Ans.
==== is strict equality operator ,it returns true only when the two operands are having the same value without any type conversion.
24.What does the delete operator do?
Ans.
The delete operator is used to delete all the variables and objects used in the program ,but it does not delete variables declared
with var keyword.
25.What does break and continue statements do?
Ans.
Continue statement continues the current loop (if label not specified) in a new iteration whereas break statement exits the current loop.
26.How to create a function using function constructor?
Ans.
The following example illustrates this
It creates a function called square with argument x and returns x multiplied by itself.
var square = new Function (“x”,”return x*x”);