javascript-exam 0 votes, 0 avg 125 123456789101112131415 JavaScript Questions 1 / 15 1. What will be the output of the following JavaScript code? // Javascript code to compare the height function height() { var height = 123.56; var type = (height>=190) ? "tall" : "short"; return type; } A. short B. 123.56 C. tall D. 190 2 / 15 2. Which of the following function of the String object returns the character in the string starting at the specified position via the specified number of characters? A. slice() B. split() C. substr() D. search() 3 / 15 3. How are windows, tabs, iframes, and frames treated according to client-side javascript? A. They are all browsing contexts B. They are all browsing information C. They are all Window contexts D. They are all Window objects 4 / 15 4. What will be the output of the following code snippet? var a = 1; var b = 0; while (a <= 3) { a++; b += a * 2; print(b); } A. 1 2 3 B. 4 10 18 C. 1 4 7 D. None of the above 5 / 15 5. What will be the function of the following JavaScript program? var scope = "js scope"; function checkscope() { var scope = "javascript scope"; function f() { return scope; } return f; } A. Returns the value in scope B. Returns value null C. Shows an error message D. Returns exception 6 / 15 6. Which JavaScript method is used to write HTML output? A. document.write() B. document.output() C. console.log() D. document.writeHTML() 7 / 15 7. What will be the output of the following code snippet? a = [1, 2, 3, 4, 5]; print(a.slice(2, 4)); A. 3, 4 B. 2, 3 C. 3, 4, 5 D. 2, 3, 4 8 / 15 8. When an operator’s value is NULL, the typeof returned by the unary operator is: A. Boolean B. Object C. Undefined D. Integer 9 / 15 9. What will be the output of the following JavaScript code? var quiz=[1,2,3]; var js=[6,7,8]; var result=quiz.concat(js); document.writeln(result); A. 1, 2, 3, 6, 7, 8 B. 123 C. 1, 2, 3 D. Error 10 / 15 10. Which one of the following is correct output for the following given JavaScript code if there is a p tag with id=demo ? functionourFunction() { document.getElementById("demo").innerHTML=Math.abs(-7.25); } A. 7 B. -7.25 C. -7 D. 25 11 / 15 11. Which function is used to serialize an object into a JSON string in Javascript? A. Stringify() B. parse() C. convert() D. None of the above 12 / 15 12. What will be the output of the following code snippet? var a = "hello"; var sum = 0; for(var i = 0; i < a.length; i++) { sum += (a[i] - 'a'); } print(sum); A. 47 B. NaN C. zero D. None of the above 13 / 15 13. Which of the following methods can be used to display data in some form using Javascript? A. document.write() B. console.log() C. window.alert() D. all of the above 14 / 15 14. What will be the output of the following code snippet? (function(a){ return (function(){ console.log(a); a = 6; })() })(21); A. 6 B. NaN C. 21 D. runtime error 15 / 15 15. Which function is used to clear the timer value? A. clearTimervalue() B. clearTimeout() C. clear() D. flush(timer) Your score is LinkedIn Facebook Twitter VKontakte 0% Restart quiz