JavaScript

1. Java Script Module 2. World Wide Web (WWW) 3. Web Terms 4. NEED FOR SCRIPT 5. Introduction to Internet Programming 6. CLIENT SIDE and SERVER SIDE Scripting 7. Different Scripting Languages 8. Introduction to JavaScript 9. JavaScript and Security 10. How to Enable JavaScript 11. Advantages of Java Script 12. Limitations with JavaScript 13. Difference between JavaScript and JAVA 14. Difference between JavaScript and VBScript 15. JavaScript Development Tools 16. JavaScript Programming Techniques 17. JavaScript terms 18. Starting with JavaScript Programming step by step 19. Time to start JavaScript Programming 20. JavaScript Variables 21. JavaScript RESERVED WORDS 22. JavaScript Data Type 23. NUMBER DATA TYPE 24. BOOLEAN DATA TYPE 25. STRING DATA TYPE 26. NULL DATA TYPE 27. JavaScript Undefined DATA TYPE 28. JavaScript Operators 29. JavaScript Arithmetic Operators 30. JavaScript Logical Operators 31. JavaScript Comparison Operators 32. JavaScript String Operators 33. Bit Manipulation Operators 34. JavaScript Assignment Operators 35. JavaScript Conditional Operator 36. Conversion between JavaScript Data Types 37. Alert JavaScript function 38. confirm JavaScript function 39. prompt JavaScript function 40. JavaScript Statements 41. Single line & Multi-line Comments 42. JavaScrip If Statement 43. JavaScript if..else Statements 44. JavaScript Ifelse..if statement. 45. JavaScript For Statement 46. JavaScript For..in Statement: 47. JavaScript While Statement 48. JavaScript do while Statement: 49. JavaScript break and continue statement 50. JavaScript switch Statement: 51. JavaScript function() 52. JavaScript function with a Return Value 53. JavaScript with Statement 54. try, catch, and throw Statements 55. JavaScript ARRAY 56. JavaScript array of different data types 57. JavaScript ARRAY and Bubble sorting Program 58. JavaScript Array Methods 59. concate() method 60. every() method 61. filter() method 62. forEach() method 63. indexOf() method 64. Join() method 65. lastIndexOf() method 66. map() method 67. reduce() method 68. reduceRight() method 69. reverse() method 70. some() method 71. toSource() method 72. toString() method 73. pop() method 74. push() method 75. shift () method 76. slice () method 77. splice () method 78. sort() method 79. unshift() method 80. EVENT handling with JavaScript 81. onblur JavaScript Event 82. onchange JavaScript Event 83. onclick JavaScript Event 84. onDblClick JavaScript Event 85. onfocus JavaScript Event 86. onkeydown JavaScript Event 87. onkeyup JavaScript Event 88. Onkeypress JavaScript Event 89. onLoad JavaScript Event 90. onMousedown JavaScript Event 91. onMouseup JavaScript Event 92. Onmouseover JavaScript Event 93. onmouseout JavaScript Event 94. onMouseMove JavaScript Event 95. onReset JavaScript Event 96. onsubmit JavaScript Event 97. onUnload JavaScript Event 98. The Screen Object 99. JavaScript Interview Part1 100. JavaScript Interview Part2 101. JavaScript Interview Part3 102. JavaScript Interview Part4 103. JavaScript Interview Part5 104. JavaScript Interview Part6 105. JavaScript Interview Part7 106. JavaScript Interview Part8 107. JavaScript Interview Part9 108. JavaScript Interview Part10
Pr.Pg Next Pg

JavaScript Interview Questions and Answers Part 2

 

11. What does isNaN function do?

  • Return true if the argument is not a number.

 

12. Whats relationship between JavaScript and ECMAScript?

Ecma Script:

  • ECMA stands for European Computer Manufacture Association.

  • ECMA script is the official name for javascript for accessing XML elements.

JavaScript:

  • JavaScript is a scripting language most often used for client-side web development. It was the originating dialect of the ECMAScript standard. ECMAScript and LiveScript are other names for JavaScript.

  • The current JavaScript that is supported in browsers is ECMAScript revision 3.

  • The below table shows the JavaScript Versions and ECMA Script Versions

 

JavaScript Version

Relationship to ECMAScript edition

JavaScript 1.1

ECMA-262, Edition 1 is based on JavaScript 1.1.

JavaScript 1.2

ECMA-262 was not complete when JavaScript 1.2 was released. JavaScript 1.2 is not fully compatible with ECMA-262, Edition 1, for the following reasons:

Netscape developed additional features in JavaScript 1.2 that were not considered for ECMA-262.

ECMA-262 adds two new features: internationalization using Unicode, and uniform behavior across all platforms. Several features of JavaScript 1.2, such as the Date object, were platform-dependent and used platform-specific behavior.

JavaScript 1.3

JavaScript 1.3 is fully compatible with ECMA-262, Edition 1.

JavaScript 1.3 resolved the inconsistencies that JavaScript 1.2 had with ECMA-262, while keeping all the additional features of JavaScript 1.2 except == and !=, which were changed to conform with ECMA-262.

JavaScript 1.4

JavaScript 1.4 is fully compatible with ECMA-262, Edition 1.

The third version of the ECMAScript specification was not finalized when JavaScript 1.4 was released.

JavaScript 1.5

JavaScript 1.5 is fully compatible with ECMA-262, Edition 3.

 

 

13. 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.


14. How do you convert numbers between different bases in JavaScript?

  • The parseInt () function is used to convert a string value into an integer.unlike eval() , parseInt() returns the first integer contained in a string or 0 if the string does not begin with an integer.

Syntax:

parseInt (string, radix)

  • There are two arguments, one of which is mandatory string argument that is the string, which is parsed to return the integer. The other argument is the, optional radix argument that specifies the base of the integer and can range from 2 to 36.

  • For example, 16 is the hexadecimal base (0123456789ABCDEF).

  • The parseInt () function is supported in all major browsers.like Internet Explorer, Chrome, FireFox, Opera, Safari etc.

  • Example, parseInt (123xyz) returns 123 and parseInt (xyz) returns 0.

  • The parseInt() function also parses hexadecimal and decimal integers.

 

  • Example :

document.write ( parseInt ( 15 )) // result will be 15 numeric

document.write ( parseInt ( F ,16 )) //result will be15 hexadecimal

document.write ( parseInt ( 1111 ,2 )) // result will be 15 from binary

document.write ( parseInt ( OxF )) // result will be 15 from hexadecimal

 

15. What is negative infinity?

  • Its a number in JavaScript, derived by dividing negative number by zero.

 

16. How to set a HTML document's background color?

  • document.bgcolor property can be set to any appropriate color

 

17. What boolean operators does JavaScript support?

  • The operators are:

  • Logical AND ( && )

  • Logical OR ( || )

  • Logical NOT ( ! )

 

18. How to get the contents of an input box using Javascript?

  • Use the "value" property.

  • var myValue = window.document.getElementById("textboxID").value;

 

19. How do JavaScript timers work?

  • Timers allow you to execute code at a set time or repeatedly using an interval. This is accomplished with the setTimeout, setInterval, and clearInterval functions.

  • The setTimeout (function, delay) function initiates a timer that calls a specific function after the delay; it returns an id value that can be used to access it later.

  • The setInterval (function, delay) function is similar to the setTimeout function except that it executes repeatedly on the delay and only stops when cancelled.

  • The clearInterval (id) function is used to stop a timer. Timers can be tricky to use since they operate within a single thread, thus events queue up waiting to execute.

 

20. How to determine the state of a checkbox using Javascript?

  • var checkedP = window.document.getElementById("CheckBoxID").checked;


Pr.Pg border                                             Next Pg