Javascript Interview Questions And Answers

Javascript Interview Questions list for experienced

  1. What is JavaScript?
  2. Enumerate the differences between Java and JavaScript?
  3. What are JavaScript types?
  4. What is the use of isNaN function?
  5. Between JavaScript and an ASP script, which is faster?
  6. What is negative infinity?
  7. Is it possible to break JavaScript Code into several lines?
  8. Which company developed JavaScript?
  9. What are undeclared and undefined variables?
  10. Write the code for adding new elements dynamically?
  11. What are global variables? How are these variable declared and what are the problems associated with using them?
  12. What is a prompt box?
  13. What is 'this' keyword in JavaScript?
  14. Explain the working of timers in JavaScript? Also elucidate the drawbacks of using the timer, if any?
  15. Which symbol is used for comments in Javascript?
  16. What is the difference between ViewState and SessionState?
  17. What is === operator?
  18. Explain how can you submit a form using JavaScript?
  19. Does JavaScript support automatic type conversion?
  20. How can the style/class of an element be changed?
  21. Explain how to read and write a file using JavaScript?
  22. What are all the looping structures in JavaScript?
  23. What is called Variable typing in Javascript?
  24. How can you convert the string of any base to integer in JavaScript?
  25. Explain the difference between "==" and "==="?
  26. What would be the result of 3+2+"7″?
  27. Explain how to detect the operating system on the client machine?
  28. What do mean by NULL in Javascript?
  29. What is the function of delete operator?
  30. What is an undefined value in JavaScript?
  31. What are all the types of Pop up boxes available in JavaScript?
  32. What is the use of Void(0)?
  33. How can a page be forced to load another page in JavaScript?
  34. What is the data type of variables of in JavaScript?
  35. What is the difference between an alert box and a confirmation box?
  36. What are escape characters?
  37. What are JavaScript Cookies?
  38. Explain what is pop()method in JavaScript?
  39. Whether JavaScript has concept level scope?
  40. Mention what is the disadvantage of using innerHTML in JavaScript?
  41. What is break and continue statements?
  42. What are the two basic groups of dataypes in JavaScript?
  43. How generic objects can be created?
  44. What is the use of type of operator?
  45. Which keywords are used to handle exceptions?
  46. Which keyword is used to print the text in the screen?
  47. What is the use of blur function?
  48. What is variable typing?
  49. How to find operating system in the client machine using JavaScript?
  50. What are the different types of errors in JavaScript?
  51. What is the use of Push method in JavaScript?
  52. What is unshift method in JavaScript?
  53. What is the difference between JavaScript and Jscript?
  54. How are object properties assigned?
  55. What is the 'Strict' mode in JavaScript and how can it be enabled?
  56. What is the way to get the status of a CheckBox?
  57. How can the OS of the client machine be detected?
  58. Explain window.onload and onDocumentReady?
  59. How will you explain closures in JavaScript? When are they used?
  60. How can a value be appended to an array?
  61. Explain the for-in loop?
  62. Describe the properties of an anonymous function in JavaScript?
  63. What is the difference between .call() and .apply()?
  64. Define event bubbling?
  65. Is JavaScript case sensitive? Give an example?
  66. What boolean operators can be used in JavaScript?
  67. How can a particular frame be targeted, from a hyperlink, in JavaScript?
  68. What is the role of break and continue statements?
  69. Write the point of difference between web-garden and a web-farm?
  70. What is the method for reading and writing a file in JavaScript?
  71. How are DOM utilized in JavaScript?
  72. How are event handlers utilized in JavaScript?
  73. Explain the role of deferred scripts in JavaScript?
  74. What are the various functional components in JavaScript?
  75. Write about the errors shown in JavaScript?
  76. What are Screen objects?
  77. Explain the unshift() method ?
  78. Define unescape() and escape() functions?
  79. What are the decodeURI() and encodeURI()?
  80. Why it is not advised to use innerHTML in JavaScript?
  81. What does the following statement declares?
  82. How are JavaScript and ECMA Script related?
  83. What is namespacing in JavaScript and how is it used?
  84. How can JavaScript codes be hidden from old browsers that don't support JavaScript?
  85. How do we add JavaScript onto a web page?
  86. Is JavaScript case sensitive?
  87. What are the types used in JavaScript?
  88. What are the boolean operators supported by JavaScript? And Operator: &&
  89. What is the difference between "==" and "==="?
  90. How to access the value of a textbox using JavaScript?
  91. What are the ways of making comments in JavaScript?
  92. How will you get the Checkbox status whether it is checked or not?
  93. How to create arrays in JavaScript?
  94. If an array with name as \"names\" contain three elements, then how will you print the third element of this array?
  95. How do you submit a form using JavaScript?
  96. What does isNaN function do?
  97. What is the use of Math Object in JavaScript?
  98. What do you understand by this keyword in JavaScript?
  99. What does \"1\"+2+4 evaluate to?
  100. What does 3+4+\"7\" evaluate to?
  101. How do you change the style/class on any element using JavaScript?
  102. Does JavaScript support foreach loop?
  103. What looping structures are there in JavaScript?
  104. What is an object in JavaScript, give an example?
  105. How you will add function as a property in a JavaScript object? Give an example.
  106. What is the similarity between the 1st and 2nd statement?
  107. What will be the output of the following statements?
  108. Consider the following statements and tell what would be the output of the logs statements? var price1 = 10; var price2 = 10; var price3 = new Number(\'10\'); // A complex numeric object because new was used. console.log(price1 === price2); console.log(price1 === price3);
  109. What would be the output of the following statements? var object1 = { same: \'same\' }; var object2 = { same: \'same\' }; console.log(object1 === object2);
  110. What would be the output of the following statements? var object1 = { same: \'same\' }; var object2 = object1; console.log(object1 === object2);
  111. What is this? var myArray = [[[]]];
  112. Name any two JavaScript functions which are used to convert nonnumeric values into numbers?
  113. Does JavaScript Support automatic type conversion, If yes give example.
  114. What is event bubbling and capturing in JavaScript?
  115. What is a closure in JavaScript?
  116. Consider the following code: 1 2 3 4 5 (function() { var a = b = 5; })(); console.log(b); What will be printed on the console?
  117. Define a repeatify function on the String object. The function accepts an integer that specifies how many times the string has to be repeated. The function returns the string repeated the number of times specified. For example: 1 console.log(\'hello\'.repeatify(3)); Should print hellohellohello.
  118. What's the result of executing this code and why. 1 2 3 4 5 6 7 8 9 10 11 function test() { console.log(a); console.log(foo()); var a = 1; function foo() { return 2; } } test();
  119. What is the result of the following code? Explain your answer. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 var fullname = \'John Doe\'; var obj = { fullname: \'Colin Ihrig\', prop: { fullname: \'Aurelio De Rosa\', getFullname: function() { return this.fullname; } } }; console.log(obj.prop.getFullname()); var test = obj.prop.getFullname; console.log(test());
  120. What's relationship between JavaScript and ECMAScript?
  121. How do you convert numbers between different bases in JavaScript?
  122. What boolean operators does JavaScript support?
  123. How do you create a new object in JavaScript?
  124. How do you assign object properties?
  125. What's a way to append a value to an array?
  126. What is this keyword?
  127. Difference between window.onload and onDocumentReady?
  128. How do you change the style/class on any element?
  129. What are Javascript closures?When would you use them?
  130. What is unobtrusive javascript? How to add behavior to an element using javascript?
  131. What is Javascript namespacing? How and where is it used?
  132. What datatypes are supported in Javascript?
  133. How to add Buttons in JavaScript?
  134. What can javascript programs do?
  135. Are you concerned that older browsers don\'t support JavaScript and thus exclude a set of Web users? individual users?
  136. In a pop-up browser window, how do you refer to the main browser window that opened it?
  137. How to write a script for \"Select\" lists using javascript
  138. What does the \"Access is Denied\" IE error mean?
  139. Is a javascript script faster than an ASP script?
  140. Are Java and JavaScript the Same?
  141. How to embed javascript in a web page?
  142. What and where are the best JavaScript resources on the Web?
  143. Can javascript code be broken in different lines?
  144. What does the EnableViewStateMac setting in an aspx page do?
  145. How is JavaScript different from Java?
  146. How do we get JavaScript onto a web page?
  147. How to read and write a file using javascript?
  148. How to detect the operating system on the client machine?
  149. How can JavaScript make a Web site easier to use? That is, are there certain JavaScript techniques that make it easier for people to use a Web site?
  150. How can JavaScript be used to improve the \"look and feel\" of a Web site? By the same token, how can JavaScript be used to improve the user interface?
  151. How do you target a specific frame from a hyperlink?
  152. What is a fixed-width table and its advantages?
  153. How to set a HTML document\'s background color?
  154. How can JavaScript be used to personalize or tailor a Web site to fit individual users?
  155. Methods GET and POST in HTML forms - what\'s the difference?
  156. Text From Your Clipboard?
  157. What are the problems associated with using JavaScript, and are there JavaScript techniques that you discourage?
  158. How to get the contents of an input box using Javascript?
  159. How to determine the state of a checkbox using Javascript?
  160. How to set the focus in an element using Javascript?
  161. How to access an external javascript file that is stored externally and not embedded?
  162. Taking a developer's perspective, do you think that that JavaScript is easy to learn and use?
  163. What Web sites do you feel use JavaScript most effectively (i.e., best-in-class examples)? The worst?
  164. How about 2+5+\"8\"?
  165. What is the difference between SessionState and ViewState?
  166. How to hide javascript code from old browsers that dont run it?
  167. How to comment javascript code?
  168. Name the numeric constants representing max,min values
  169. What is the Document Object?
  170. What do Events mean?
  171. Enlist Javascript features.
  172. element javascript method call?

Javascript interview questions and answers on advance and basic Javascript with example so this page for both freshers and experienced condidate. Fill the form below we will send the all interview questions on Javascript also add your Questions if any you have to ask and for apply in Javascript Tutorials and Training course just send a mail on info@pcds.co.in in detail about your self.

Top Javascript interview questions and answers for freshers and experienced

What is Javascript ?

Answer :

Questions : 1 :: What is JavaScript?

JavaScript is a client-side scripting language that can be inserted into HTML pages and is understood by web browsers.

Questions : 2 :: Enumerate the differences between Java and JavaScript?

java is a complete programming language. In contrast, JavaScript is a coded program that can be introduced to HTML pages. These two languages are not at all inter-dependent and are designed for the...View answers

Questions : 3 :: What are JavaScript types?


Following are the JavaScript types: Number String Boolean Function Object Null Undefined

Questions : 4 :: What is the use of isNaN function?

isNan function returns true if the argument is not a number otherwise it is false.

Questions : 5 :: Between JavaScript and an ASP script, which is faster?

JavaScript is faster. JavaScript is a client-side language and thus it does not need the assistance of the web server to execute. On the other hand, ASP is a server-side language and hence is always...View answers

Questions : 6 :: What is negative infinity?


Negative Infinity is a number in JavaScript which can be derived by dividing negative number by zero.

Questions : 7 :: Is it possible to break JavaScript Code into several lines?

Breaking within a string statement can be done by the use of a backslash, ‘’, at the end of the first line Example: document.write("This is a...View answers

Questions : 8 :: Which company developed JavaScript?

Netscape is the software company who developed JavaScript.

Questions : 9 :: What are undeclared and undefined variables?


Undeclared variables are those that do not exist in a program and are not declared. If the program tries to read the value of an undeclared variable, then a runtime error is encountered. Undefined...View answers

Questions : 10 :: Write the code for adding new elements dynamically?

XHTML <html> <head> <title>t1</title> <script type="text/javascript"> function addNode() { var newP = document.createElement("p"); var textNode =...View answers

Questions : 11 :: What are global variables? How are these variable declared and what are the problems associated with using them?

Global variables are those that are available throughout the length of the code, that is, these have no scope. The var keyword is used to declare a local variable or object. If the var keyword is...View answers

Questions : 12 :: What is a prompt box?

A prompt box is a box which allows the user to enter input by providing a text box.  Label and box will be provided to enter the text or number.

Questions : 13 :: What is 'this' keyword in JavaScript?

‘This’ keyword is used to point at the current object in the code. For instance: If the code is presently at an object created by the help of the ‘new’ keyword, then...View answers

Questions : 14 :: Explain the working of timers in JavaScript? Also elucidate the drawbacks of using the timer, if any?

Timers are used to execute a piece of code at a set time or also to repeat the code in a given interval of time. This is done by using the functions setTimeout,...View answers

Questions : 15 :: Which symbol is used for comments in Javascript?

// for Single line comments and /*   Multi Line Comment */

Questions : 16 :: What is the difference between ViewState and SessionState?

‘ViewState’ is specific to a page in a session. ‘SessionState’ is specific to user specific data that can be accessed across all pages in the web application.

Questions : 17 :: What is === operator?

=== is called as strict equality operator which returns true when the two operands are having the same value without any type conversion.

Questions : 18 :: Explain how can you submit a form using JavaScript?

To submit a form using JavaScript use document.form[0].submit(); document.form[0].submit();

Questions : 19 :: Does JavaScript support automatic type conversion?

Yes JavaScript does support automatic type conversion, it is the common way of type conversion used by JavaScript developers

Questions : 20 :: How can the style/class of an element be changed?

It can be done in the following way: document.getElementById(“myText”).style.fontSize =...View answers

Questions : 21 :: Explain how to read and write a file using JavaScript?

There are two ways to read and write a file using JavaScript Using JavaScript extensions Using a web page and Active X objects

Questions : 22 :: What are all the looping structures in JavaScript?

Following are looping structures in Javascript: For While do-while loops

Questions : 23 :: What is called Variable typing in Javascript?

Variable typing is used to assign a number to a variable and the same variable can be assigned to a string. Example i = 10; i =...View answers

Questions : 24 :: How can you convert the string of any base to integer in JavaScript?

The parseInt() function is used to convert numbers between different bases. parseInt() takes the string to be converted as its first parameter, and the second parameter is the base of the given...View answers

Questions : 25 :: Explain the difference between "==" and "==="?

“==” checks only for equality in value whereas “===” is a stricter equality test and returns false if either the value or the type of the two variables are different.

Questions : 26 :: What would be the result of 3+2+"7″?

Since 3 and 2 are integers, they will be added numerically. And since 7 is a string, its concatenation will be done. So the result would be 57.

Questions : 27 :: Explain 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.

Questions : 28 :: What do mean by NULL in Javascript?

The NULL value is used to represent no value or no object.  It implies no object or null string, no valid boolean value, no number and no array object.

Questions : 29 :: What is the function of delete operator?

The functionality of delete operator is used to delete all variables and objects in a program but it cannot delete variables declared with VAR keyword.

Questions : 30 :: What is an undefined value in JavaScript?

Undefined value means the Variable used in the code doesn’t exist Variable is not assigned to any value Property doesn’t exist

Questions : 31 :: What are all the types of Pop up boxes available in JavaScript?

Alert Confirm and Prompt

Questions : 32 :: What is the use of Void(0)?

Void(0) is used to prevent the page from refreshing and parameter “zero” is passed while calling. Void(0) is used to call another method without refreshing the page.

Questions : 33 :: How can a page be forced to load another page in JavaScript?

The following code has to be inserted to achieve the desired effect: <script language="JavaScript" type="text/javascript" > <!--...View answers

Questions : 34 :: What is the data type of variables of in JavaScript?

All variables in the JavaScript are object data types.

Questions : 35 :: What is the difference between an alert box and a confirmation box?

An alert box displays only one button which is the OK button. But a Confirmation box displays two buttons namely OK and cancel.

Questions : 36 :: What are escape characters?

Escape characters (Backslash) is used when working with special characters like single quotes, double quotes, apostrophes and ampersands. Place backslash before the characters to make it...View answers

Questions : 37 :: What are JavaScript Cookies?

Cookies are the small test files stored in a computer and it gets created when the user visits the websites to store information that they need. Example could be User Name details and shopping cart...View answers

Questions : 38 :: Explain what is pop()method in JavaScript?

The pop() method is similar as the shift() method but the difference is that the Shift method works at the end of the array.  Also the pop() method take the last element off of the given array...View answers

Questions : 39 :: Whether JavaScript has concept level scope?

No. JavaScript does not have concept level scope. The variable declared inside the function has scope inside the function.

Questions : 40 :: Mention what is the disadvantage of using innerHTML in JavaScript?

If you use innerHTML in JavaScript the disadvantage is Content is replaced everywhere We cannot use like “appending to innerHTML” Even if you use +=like “innerHTML = innerHTML...View answers

Questions : 41 :: What is break and continue statements?

Break statement exits from the current loop. Continue statement continues with next statement of the loop.

Questions : 42 :: What are the two basic groups of dataypes in JavaScript?

They are as – Primitive Reference types.

Questions : 43 :: How generic objects can be created?

Generic objects can be created as: var I = new...View answers

Questions : 44 :: What is the use of type of operator?

‘Typeof’ is an operator which is used to return a string description of the type of a variable.

Questions : 45 :: Which keywords are used to handle exceptions?

Try… Catch—finally is used to handle exceptions in the JavaScript Try{ Code } Catch(exp){ Code to throw an exception } Finally{ Code runs either it finishes...View answers

Questions : 46 :: Which keyword is used to print the text in the screen?

document.write(“Welcome”) is used to print the text – Welcome in the screen.

Questions : 47 :: What is the use of blur function?

Blur function is used to remove the focus from the specified object.

Questions : 48 :: What is variable typing?

Variable typing is used to assign a number to a variable and then assign string to the same variable. Example is as follows: i=...View answers

Questions : 49 :: How to find operating system in the client machine using JavaScript?

The ‘Navigator.appversion’ is used to find the name of the operating system in the client machine.

Questions : 50 :: What are the different types of errors in JavaScript?

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...View answers

Questions : 51 :: What is the use of Push method in JavaScript?

The push method is used to add or append one or more elements to the end of an Array. Using this method, we can append multiple elements by passing multiple arguments

Questions : 52 :: What is unshift method in JavaScript?

Unshift method is like push method which works at the beginning of the array.  This method is used to prepend one or more elements to the beginning of the array.

Questions : 53 :: What is the difference between JavaScript and Jscript?

Both are almost similar. JavaScript is developed by Netscape and Jscript was developed by Microsoft .

Questions : 54 :: How are object properties assigned?

Properties are assigned to objects in the following way – obj["class"] = 12; 1 obj["class"]=12; or obj.class =...View answers

Questions : 55 :: What is the 'Strict' mode in JavaScript and how can it be enabled?

Strict Mode adds certain compulsions to JavaScript. Under the strict mode, JavaScript shows errors for a piece of codes, which did not show an error before, but might be problematic and potentially...View answers

Questions : 56 :: What is the way to get the status of a CheckBox?

The status can be acquired as follows – alert(document.getElementById(‘checkbox1′).checked); If the CheckBox will be checked, this alert will return TRUE.

Questions : 57 :: How can the OS of the client machine be detected?

The navigator.appVersion string can be used to detect the operating system on the client machine.

Questions : 58 :: Explain window.onload and onDocumentReady?

The onload function is not run until all the information on the page is loaded. This leads to a substantial delay before any code is executed. onDocumentReady loads the code just after the DOM is...View answers

Questions : 59 :: How will you explain closures in JavaScript? When are they used?

Closure is a locally declared variable related to a function which stays in memory when the function has returned. For example: JavaScript function greet(message)...View answers

Questions : 60 :: How can a value be appended to an array?

A value can be appended to an array in the given manner – arr[arr.length] = value;

Questions : 61 :: Explain the for-in loop?

The for-in loop is used to loop through the properties of an object. The syntax for the for-in loop is – for (variable name in object){ statement or block to...View answers

Questions : 62 :: Describe the properties of an anonymous function in JavaScript?

A function that is declared without any named identifier is known as an anonymous function. In general, an anonymous function is inaccessible after its declaration. Anonymous function declaration...View answers

Questions : 63 :: What is the difference between .call() and .apply()?

The function .call() and .apply() are very similar in their usage except a little difference. .call() is used when the number of the function’s arguments are known to the programmer, as they...View answers

Questions : 64 :: Define event bubbling?

JavaScript allows DOM elements to be nested inside each other. In such a case, if the handler of the child is clicked, the handler of parent will also work as if it were clicked too.

Questions : 65 :: Is JavaScript case sensitive? Give an example?

Yes, JavaScript is case sensitive. For example, a function parseInt is not same as the function Parseint.

Questions : 66 :: What boolean operators can be used in JavaScript?

The ‘And’ Operator (&&), ‘Or’  Operator (||) and the ‘Not’ Operator (!) can be used in JavaScript. *Operators are without the...View answers

Questions : 67 :: How can a particular frame be targeted, from a hyperlink, in JavaScript?

This can be done by including the name of the required frame in the hyperlink using the ‘target’ attribute. <a href=”newpage.htm” target=”newframe”>>New...View answers

Questions : 68 :: What is the role of break and continue statements?

Break statement is used to come out of the current loop while the continue statement continues the current loop with a new recurrence.

Questions : 69 :: Write the point of difference between web-garden and a web-farm?

Both web-garden and web-farm are web hosting systems. The only difference is that web-garden is a setup that includes many processors in a single server while web-farm is a larger setup that uses...View answers

Questions : 70 :: What is the method for reading and writing a file in JavaScript?

This can be done by Using JavaScript extensions (runs from JavaScript Editor), example for opening of a file – fh = fopen(getScriptPath(),...View answers

Questions : 71 :: How are DOM utilized in JavaScript?

DOM stands for Document Object Model and is responsible for how various objects in a document interact with each other. DOM is required for developing web pages, which includes objects like...View answers

Questions : 72 :: How are event handlers utilized in JavaScript?

Events are the actions that result from activities, such as clicking a link or filling a form, by the user. An event handler is required to manage proper execution of all these events. Event handlers...View answers

Questions : 73 :: Explain the role of deferred scripts in JavaScript?

By default, the parsing of the HTML code, during page loading, is paused until the script has not stopped executing. It means, if the server is slow or the script is particularly heavy, then the...View answers

Questions : 74 :: What are the various functional components in JavaScript?

The different functional components in JavaScript are- First-class functions: Functions in JavaScript are utilized as first class objects. This usually means that these functions can be passed...View answers

Questions : 75 :: Write about the errors shown in JavaScript?

JavaScript gives a message if it encounters an error. The recognized errors are – Load-time errors: The errors shown at the time of the page loading are counted under Load-time errors. These...View answers

Questions : 76 :: What are Screen objects?

Screen objects are used to read the information from the client’s screen. The properties of screen objects are – AvalHeight: Gives the height of client’s screen AvailWidth:...View answers

Questions : 77 :: Explain the unshift() method ?

This method is functional at the starting of the array, unlike the push(). It adds the desired number of elements to the top of an array. For example – JavaScript var name = [ "john"...View answers

Questions : 78 :: Define unescape() and escape() functions?

The escape () function is responsible for coding a string so as to make the transfer of the information from one computer to the other, across a network. For...View answers

Questions : 79 :: What are the decodeURI() and encodeURI()?

EncodeURl() is used to convert URL into their hex coding. And DecodeURI() is used to convert the encoded URL back to normal. JavaScript <script> var uri="my...View answers

Questions : 80 :: Why it is not advised to use innerHTML in JavaScript?

innerHTML content is refreshed every time and thus is slower. There is no scope for validation in innerHTML and, therefore, it is easier to insert rouge code in the document and, thus, make the web...View answers

Questions : 81 :: What does the following statement declares?

var myArray = [[[]]]; 1 varmyArray=[[[]]]; It declares a three dimensional...View answers

Questions : 82 :: How are JavaScript and ECMA Script related?

ECMAScript is nothing but another name for JavaScript. Precisely, ECMAScript is the formal name of JavaScript, when XML elements have to be accessed.

Questions : 83 :: What is namespacing in JavaScript and how is it used?

Namespacing is used for grouping the desired functions, variables etc. under a unique name. It is a name that has been attached to the desired functions, objects and properties. This improves...View answers

Questions : 84 :: How can JavaScript codes be hidden from old browsers that don't support JavaScript?

For hiding JavaScript codes from old browsers: Add “<!–” without the quotes in the code just after the <script> tag. Add “//–>” without the...View answers

Questions : 85 :: How do we add JavaScript onto a web page?

Ans:There are several way for adding JavaScript on a web page, but there are two ways which are commonly used by developers If your script code is very short and only for single page, then following...View answers

Questions : 86 :: Is JavaScript case sensitive?

Yes! A function getElementById is not the same as getElementbyID.

Questions : 87 :: What are the types used in JavaScript?

Ans:String, Number, Boolean, Function, Object, Null, Undefined.

Questions : 88 :: What are the boolean operators supported by JavaScript? And Operator: &&

Or Operator: || Not Operator: !

Questions : 89 :: What is the difference between "==" and "==="?

“==” checks equality only, “===” checks for equality as well as the type.

Questions : 90 :: How to access the value of a textbox using JavaScript?

Code <!DOCTYPE html> <html> <body> Full name: <input type="text" id="txtFullName" name="FirstName" value="Vikas Ahlawat"> </body> </html> There...View answers

Questions : 91 :: What are the ways of making comments in JavaScript?

// is used for line comments ex:- var x=10; //comment text /* */ is used for block comments ex:- var x= 10; /* this is block comment...View answers

Questions : 92 :: How will you get the Checkbox status whether it is checked or not?

var status = document.getElementById('checkbox1').checked; alert(status); will return true or...View answers

Questions : 93 :: How to create arrays in JavaScript?

here are two ways to create array in JavaScript like other languages: a) The first way to create array Declare Array: Code var names = new Array(); Add Elements in Array:- names[0] =...View answers

Questions : 94 :: If an array with name as "names" contain three elements, then how will you print the third element of this array?

Ans: Print third array element document.write(names[2]); Note:- Array index starts with 0.

Questions : 95 :: How do you submit a form using JavaScript?

Use document.forms[0].submit();

Questions : 96 :: What does isNaN function do?

It returns true if the argument is not a number. Example: Code document.write(isNaN("Hello")+ "<br>"); document.write(isNaN("2013/06/23")+ "<br>"); document.write(isNaN(123)+...View answers

Questions : 97 :: What is the use of Math Object in JavaScript?

The math object provides you properties and methods for mathematical constants and functions. ex:- Code var x = Math.PI; // Returns PI var y = Math.sqrt(16); // Returns the square root of 16 var...View answers

Questions : 98 :: What do you understand by this keyword in JavaScript?

In JavaScript the this is a context-pointer and not an object pointer. It gives you the top-most context that is placed on the stack. The following gives two different results (in the browser, where...View answers

Questions : 99 :: What does "1"+2+4 evaluate to?

Since 1 is a string, everything is a string, so the result is 124.

Questions : 100 :: What does 3+4+"7" evaluate to?

Since 3 and 4 are integers, this is number arithmetic, since 7 is a string, it is concatenation, so 77 is the result.

Questions : 101 :: How do you change the style/class on any element using JavaScript?

Code document.getElementById(“myText”).style.fontSize = “10"; -or- document.getElementById(“myText”).className =...View answers

Questions : 102 :: Does JavaScript support foreach loop?

JavaScript 1.6(ECMAScript 5th Edition) support foreach loop, See example here http://jsfiddle.net/gpDWk/

Questions : 103 :: What looping structures are there in JavaScript?

for, while, do-while loops

Questions : 104 :: What is an object in JavaScript, give an example?

An object is just a container for a collection of named values: // Create the man object Code var man = new Object(); man.name = 'Vikas Ahlawat'; man.living = true; man.age =...View answers

Questions : 105 :: How you will add function as a property in a JavaScript object? Give an example.

Code var man = new Object(); man.name = 'Vikas Ahlawat'; man.living = true; man.age = 27; man.getName = function() { return man.name;} console.log(man.getName()); // Logs 'Vikas...View answers

Questions : 106 :: What is the similarity between the 1st and 2nd statement?

1st:- var myString = new String('male'); // An object. 2nd:- var myStringLiteral = 'male'; // Primitive string value, not an object. Ans: Both will call String() constructor function You can...View answers

Questions : 107 :: What will be the output of the following statements?

var myString = 'Vikas' // Create a primitive string object. var myStringCopy = myString; // Copy its value into a new variable. var myString = null; // Manipulate the value console.log(myString,...View answers

Questions : 108 :: Consider the following statements and tell what would be the output of the logs statements? var price1 = 10; var price2 = 10; var price3 = new Number('10'); // A complex numeric object because new was used. console.log(price1 === price2); console.log(price1 === price3);

console.log(price1 === price2); // Logs true. console.log(price1 === price3); /* Logs false because price3 contains a complex number object and price 1 is a primitive value....View answers

Questions : 109 :: What would be the output of the following statements? var object1 = { same: 'same' }; var object2 = { same: 'same' }; console.log(object1 === object2);

Logs false, JavaScript does not care that they are identical and of the same object type. When comparing complex objects, they are equal only when they reference the same object (i.e., have the same...View answers

Questions : 110 :: What would be the output of the following statements? var object1 = { same: 'same' }; var object2 = object1; console.log(object1 === object2);

Logs true

Questions : 111 :: What is this? var myArray = [[[]]];

Three dimensional array

Questions : 112 :: Name any two JavaScript functions which are used to convert nonnumeric values into numbers?

Number() parseInt() parseFloat() Code var n1 = Number(“Hello world!”); //NaN var n2 = Number(“”); //0 var n3 = Number(“000010”); //10 var...View answers

Questions : 113 :: Does JavaScript Support automatic type conversion, If yes give example.

Yes! Javascript support automatic type conversion. You should take advantage of it, It is most common way of type conversion used by Javascript developers. Ex. var s = '5'; var a = s*1; var b =...View answers

Questions : 114 :: What is event bubbling and capturing in JavaScript?

Event bubbling is series of events when : An event is triggered on the inner most element first and then it triggers on the parent elements in nested order. DOM elements could be nested inside each...View answers

Questions : 115 :: What is a closure in JavaScript?

JavaScript allows you to declare a function within another function, and the local variables still can be accessible even after returning from the function you called. In other words,...View answers

Questions : 116 :: Consider the following code: 1 2 3 4 5 (function() { var a = b = 5; })(); console.log(b); What will be printed on the console?

The code above prints 5. The trick of this question is that in the IIFE there are two assignments but the variable a is declared using the keyword var. What this means is that a is a local variable...View answers

Questions : 117 :: Define a repeatify function on the String object. The function accepts an integer that specifies how many times the string has to be repeated. The function returns the string repeated the number of times specified. For example: 1 console.log('hello'.repeatify(3)); Should print hellohellohello.

  A possible implementation is shown below: 1 2 3 4 5 6 7 8 9 String.prototype.repeatify = String.prototype.repeatify || function(times) {    var str...View answers

Questions : 118 :: What's the result of executing this code and why. 1 2 3 4 5 6 7 8 9 10 11 function test() { console.log(a); console.log(foo()); var a = 1; function foo() { return 2; } } test();

The result of this code is undefined and 2. The reason is that both variables and functions are hoisted (moved at the top of the function) but variables don’t retain any assigned value. So, at...View answers

Questions : 119 :: What is the result of the following code? Explain your answer. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 var fullname = 'John Doe'; var obj = { fullname: 'Colin Ihrig', prop: { fullname: 'Aurelio De Rosa', getFullname: function() { return this.fullname; } } }; console.log(obj.prop.getFullname()); var test = obj.prop.getFullname; console.log(test());

The code prints Aurelio De Rosa and John Doe. The reason is that the context of a function, what is referred with the this keyword, in JavaScript depends on how a function is invoked, not how...View answers

Questions : 120 :: What's relationship between JavaScript and ECMAScript?

ECMAScript is yet another name for JavaScript (other names include LiveScript). The current JavaScript that you see supported in browsers is ECMAScript revision 3.

Questions : 121 :: How do you convert numbers between different bases in JavaScript?

Use the parseInt() function, that takes a string as the first parameter, and the base as a second parameter. So to convert hexadecimal 3F to decimal, use parseInt ("3F", 16);

Questions : 122 :: What boolean operators does JavaScript support?

&&, || and !

Questions : 123 :: How do you create a new object in JavaScript?

var obj = new Object(); or var obj = {};

Questions : 124 :: How do you assign object properties?

obj["age"] = 17 or obj.age = 17.

Questions : 125 :: What's a way to append a value to an array?

arr[arr.length] = value;

Questions : 126 :: What is this keyword?

It refers to the current object.

Questions : 127 :: Difference between window.onload and onDocumentReady?

The onload event does not fire until every last piece of the page is loaded, this includes css and images, which means there’s a huge delay before any code is executed. That isnt what we want....View answers

Questions : 128 :: How do you change the style/class on any element?

document.getElementById(“myText”).style.fontSize = “20”; -or- document.getElementById(“myText”).className = “anyclass”;

Questions : 129 :: What are Javascript closures?When would you use them?

Two one sentence summaries: * a closure is the local variables for a function – kept alive after the function has returned, or * a closure is a stack-frame which is not deallocated when the...View answers

Questions : 130 :: What is unobtrusive javascript? How to add behavior to an element using javascript?

Unobtrusive Javascript refers to the argument that the purpose of markup is to describe a document’s structure, not its programmatic behavior and that combining the two negatively impacts a...View answers

Questions : 131 :: What is Javascript namespacing? How and where is it used?

Using global variables in Javascript is evil and a bad practice. That being said, namespacing is used to bundle up all your functionality using a unique name. In JavaScript, a namespace is really...View answers

Questions : 132 :: What datatypes are supported in Javascript?

Number, String, Undefined, null, Boolean 10. What is the difference between innerHTML and append() in JavaScript? InnerHTML is not standard, and its a String. The DOM is not, and although innerHTML...View answers

Questions : 133 :: How to add Buttons in JavaScript?

 The most basic and ancient use of buttons are the "submit" and "clear", which appear slightly beforethe Pleistocene period. Notice when the "GO!" button is pressed it submits itself to...View answers

Questions : 134 :: What can javascript programs do?

Generation of HTML pages on-the-fly without accessing the Web server. The user can be given controlover the browser like User input validation Simple computations can be performed on the...View answers

Questions : 135 :: Are you concerned that older browsers don't support JavaScript and thus exclude a set of Web users? individual users?

Fragmentation of the installed base of browsers will only get worse. By definition, it can never improveunless absolutely everyone on the planet threw away their old browsers and upgraded to the...View answers

Questions : 136 :: In a pop-up browser window, how do you refer to the main browser window that opened it?

Use window.opener to refer to the main window from pop-ups.

Questions : 137 :: How to write a script for "Select" lists using javascript

1. To remove an item from a list set it to nullmySelectObject.options[3] = null;2. To truncate a list set its length to the maximum size you desiremySelectObject.length = 2;3. To delete all options...View answers

Questions : 138 :: 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'sdomain is different from the...View answers

Questions : 139 :: 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 itscomputation,so it is always faster than any server-side script like ASP,PHP,etc..

Questions : 140 :: 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 clientsidescripting language with some...View answers

Questions : 141 :: How to embed javascript in a web page?

javascript code can be embedded in a web page between <script langugage="javascript"></script> tags

Questions : 142 :: What and where are the best JavaScript resources on the Web?

The Web has several FAQ areas on JavaScript. The best place to start is something called the meta-FAQ [14-Jan-2001 Editor's Note: I can't point to it anymore, it is broken!], which provides a...View answers

Questions : 143 :: 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 otherjavascript statement.that is ,document.write("Hello world");

Questions : 144 :: What does the EnableViewStateMac setting in an aspx page do?

Setting EnableViewStateMac=true is a security measure that allows ASP.NET to ensure that theviewstate for a page has not been tampered with. If on Postback, the ASP.NET framework detects thatthere...View answers

Questions : 145 :: How is JavaScript different from Java?

JavaScript was developed by Brendan Eich of Netscape; Java was developed at Sun Microsystems. While the two languages share some common syntax, they were developed independently of each other and for...View answers

Questions : 146 :: How do we get JavaScript onto a web page?

You can use several different methods of placing javascript in you pages. You can directly add a script element inside the body of page. 1. For example, to add the "last updated line" to your...View answers

Questions : 147 :: 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.

Questions : 148 :: 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.

Questions : 149 :: How can JavaScript make a Web site easier to use? That is, are there certain JavaScript techniques that make it easier for people to use a Web site?

JavaScript's greatest potential gift to a Web site is that scripts can make the page more immediately interactive, that is, interactive without having to submit every little thing to the server for...View answers

Questions : 150 :: How can JavaScript be used to improve the "look and feel" of a Web site? By the same token, how can JavaScript be used to improve the user interface?

On their own, Web pages tend to be lifeless and flat unless you add animated images or more bandwidth-intensive content such as Java applets or other content requiring plug-ins to operate (ShockWave...View answers

Questions : 151 :: How do you target a specific frame from a hyperlink?

Include the name of the frame in the target attribute of the hyperlink. <a href=”mypage.htm” target=”myframe”>>My Page</a>

Questions : 152 :: What is a fixed-width table and its advantages?

Fixed width tables are rendered by the browser based on the widths of the columns in the first row, resulting in a faster display in case of large tables. Use the CSS style table-layout:fixed to...View answers

Questions : 153 :: How to set a HTML document's background color?

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

Questions : 154 :: How can JavaScript be used to personalize or tailor a Web site to fit individual users?

JavaScript allows a Web page to perform "if-then" kinds of decisions based on browser version, operating system, user input, and, in more recent browsers, details about the screen size in which the...View answers

Questions : 155 :: Methods GET and POST in HTML forms - what's the difference?

GET: Parameters are passed in the querystring. Maximum amount of data that can be sent via the GET method is limited to about 2kb.POST: Parameters are passed in the request body. There is no limit to...View answers

Questions : 156 :: Text From Your Clipboard?

It is true, text you last copied for pasting (copy & paste) can be stolen when you visit web sites using a combination of JavaScript and ASP (or PHP, or CGI) to write your possible sensitive data...View answers

Questions : 157 :: What are the problems associated with using JavaScript, and are there JavaScript techniques that you discourage?

Browser version incompatibility is the biggest problem. It requires knowing how each scriptable browser version implements its object model. You see, the incompatibility rarely has to do with the...View answers

Questions : 158 :: How to get the contents of an input box using Javascript?

Use the "value" property. var myValue = window.document.getElementById("MyTextBox").value;

Questions : 159 :: How to determine the state of a checkbox using Javascript?

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

Questions : 160 :: How to set the focus in an element using Javascript?

<script> function setFocus() { if(focusElement != null) { document.forms[0].elements["myelementname"].focus(); } } </script>

Questions : 161 :: 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>How to access an external javascript file that is stored externally...View answers

Questions : 162 :: Taking a developer's perspective, do you think that that JavaScript is easy to learn and use?

One of the reasons JavaScript has the word "script" in it is that as a programming language, the vocabulary of the core language is compact compared to full-fledged programming languages. If you...View answers

Questions : 163 :: What Web sites do you feel use JavaScript most effectively (i.e., best-in-class examples)? The worst?

The best sites are the ones that use JavaScript so transparently, that I'm not aware that there is any scripting on the page. The worst sites are those that try to impress me with how much scripting...View answers

Questions : 164 :: How about 2+5+"8"?

Since 2 and 5 are integers, this is number arithmetic, since 8 is a string, it’s concatenation, so 78 is the result.

Questions : 165 :: What is the difference between SessionState and ViewState?

ViewState is specific to a page in a session. Session state refers to user specific data that can be accessed across all pages in the web application.

Questions : 166 :: How to hide javascript code from old browsers that dont run it?

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...View answers

Questions : 167 :: How to comment javascript code?

Use // for line comments and/**/ for block comments

Questions : 168 :: Name the numeric constants representing max,min values

Number.MAX_VALUENumber.MIN_VALUE

Questions : 169 :: What is the Document Object?

Each HTML document loaded into a browser window becomes a document object. It provides access to all HTML elements in a page from within the script. The document object is a part of the window...View answers

Questions : 170 :: What do Events mean?

Events allow you to write a javascript code that reacts to certain situations. They are actions detected by javascript. Every element on a web page has certain events that can trigger a javascript...View answers

Questions : 171 :: Enlist Javascript features.

Lightweight interpreted open and cross-platform created for the network-centric...View answers

Questions : 172 :: element javascript method call?

We can explain the javascript method and object value with the value is div tag in html. In coding basic level is html. there have various tag.<div *dxTemplate="let cell of 'valueTemplate'">...View answers
More Question

Ask your interview questions on Javascript

Write Your comment or Questions if you want the answers on Javascript from Javascript Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---