Test Series - html

Test Number 47/72

Q: External scripts can’t take the tag _________
A. . When one wants to write a message in console, console.log() is used. The window.alert() alerts message in box on window.
Q: For displaying data in JavaScript, we can’t use ____________
A. document.write()
B. console.log()
C. innerHTML
D. document.getElementById()
Solution: We can display data in many ways in JavaScript.They are innerHTML, console.log(), window.alert(), document.write. document.getElementById(id) is a method used for accessing HTML element by JavaScript. Here id defines the HTML element.
Q: For testing we should use ________
A. document.write()
B. console.log()
C. window.alert()
D. innerHTML
Solution: For testing we used document.write() in JavaScript. If we use document.write() after HTML document, it will delete all existing HTML. This method can only be used for testing purposes.
 
Q: Which of the following keyword stops the execution of JavaScript?
A. break
B. return
C. debugger
D. try….catch
Solution: By using debugger keyword execution of JavaScript stops, and is debugger function is defined it is called at the moment, break is the keyword used to terminate a loop or a switch, return is used for exit from a function, try…catch handle the errors.
Q: Arrays in JavaScript are written within ____________
A. {}
B. [].
C. “”
D. ()
Solution: Arrays in JavaScript are written in square brackets. The elements of array are separated by commas. Index of array items starts from 0. E.g. var fruits= [“apple”, “orange”, “banana”, “pine-apple”]; objects in JavaScript are written inside curly brackets.
Q: typeof “null” in JavaScript is _______
A. number
B. string
C. object
D. undefined
Solution: typeof “null” in JavaScript is an object. Basically null indicates nothing like it is a thing that does not exist. It is like a bug in JavaScript that its typeof comes to be an object. For emptying an object we can set it to null.
Q: Negative positions for string do not work in ______________
A. Internet Explorer 8
B. Chrome
C. Safari
D. Opera
Solution: While using slice(), substr() and substring() method we pass numbers as parameters respective to the string. E.g var tes= str.slice(-10). -10 is indicates negative position. It does not work in Internet Explorer or older versions.
Q: For converting string to array we can use ______________ method.
A. charAt()
B. charCodeAt()
C. split()
D. toLowerCase()
Solution: For converting any string to an array we use split() method. E.g. var tr=”t,o,I,k,l”; tr.split(“,”); tr.split(“|”); tr.split(“ ”); charAt returns a character from the given index, charCodeAt() returns Unicode of character at the given index. toLowerCase() method converts input string into lower case string.
Q: JavaScript numbers are stored as ______________
A. integers
B. double precision floating point
C. double
D. floating point
Solution: The numbers according to international IEEE 754 standard are stored as a double precision floating point. It stores the numbers in 64-bit format, stored in bits from 0 to 51, exponent in bits is from 52 to 62 and signs in a bit is 63.
Q: The integers in JavaScript are precise up to ___________
A. 12 digits
B. 10 digits
C. 23 digits
D. 15 digits
Solution: The integers in JavaScript have accuracy up to 15 digits. E.g. var y=111111111111111; // value of y will be 111111111111111. For decimal the maximum number of decimals is 17.

You Have Score    /10