What is JavaScript?
a) JavaScript is a scripting language used to make the website interactive
b) JavaScript is an assembly language used to make the website interactive
c) JavaScript is a compiled language used to make the website interactive
d) None of the mentioned
What will be the output of the following JavaScript code?
<p id="demo"></p>
<script>
var js = 10;
js *= 5;
document.getElementById("demo").innerHTML = js;
</script>
a) 10
b) 50
c) 5
d) Error
What will be the output of the following JavaScript code snippet?
// JavaScript Equalto Operators
function equalto()
{
int num=10;
if(num==="10")
return true;
else
return false;
}
a) false
b) true
c) compilation error
d) runtime error
Which of the following object is the main entry point to all client-side
JavaScript features and APIs?
a) Position
b) Window
c) Standard
d) Location
What will be the result or type of error if p is not defined in the
following JavaScript code snippet?
console.log(p)
a) Value not found Error
b) Reference Error
c) Null
d) Zero
Why event handlers is needed in JS?
a) Allows JavaScript code to alter the behaviour of windows
b) Adds innerHTML page to the code
c) Change the server location
d) Performs handling of exceptions and occurrences
What will be the firstname and surname of the following JavaScript
program?
var book = {
"main title": "JavaScript",
'sub-title': "The Definitive Guide",
"for": "all audiences",
author: {
firstname: "David",
surname: "Flanagan"
}
};
a) objects
b) property names
c) properties
d) property values
What is the purpose of the parameter $name ?
a) Document Name
b) Input Name
c) Output Name
d) ID
Which of the following is not an example of closures?
a) Objects
b) Variables
c) Functions
d) Graphics
In general, event handler is nothing but ____________
a) function
b) interface
c) event
d) handler
What will be the output of the following JavaScript statement?
var grand_Total=eval("10*10+5");
a) 10*10+5
b) 105 as a string
c) 105 as an integer value
d) Exception is thrown
What will be the equivalent statement of the following JavaScript
statement?
var o = new Object();
a) var o = Object();
b) var o;
c) var o= new Object;
d) Object o=new Object();
What will be the last statement return in the following JavaScript code?
function constfuncs()
{
var funcs = [];
for(var i = 0; i < 10; i++)
funcs[i] = function() { return i; };
return funcs;
}
var funcs = constfuncs();
funcs[5]()
a) 9
b) 0
c) 10
d) 12
The "function" and " var" are known as:
a) Keywords
b) Data types
c) Declaration statements
d) Prototypes
What will be the output of the following JavaScript code?
var arr = [7, 5, 9, 1];
var min = Math.min.apply(null, arr);
document.writeln(min);
a) 7
b) 5
c) 1
d) 9
Which of the following syntax can be used to write "Hello World" in an
alert box?
a) alertBox("Hello World");
b) msgBox("Hello World");
c) alert("Hello World");
d) msg("Hello World");
What was the original name of JavaScript when it discovered?
a) LiveScript
b) EScript
c) JScript
d) Mocha
Which of the following built-in method is used to remove the last
element from an array and return that element?
a) last()
b) pop()
c) get()
d) None of the above.
Which JavaScript operator is used to determine the type of a
variable?
A. typeof
B. TypeOf
C. typeOf
D. sizeof
What will be the output of the following JavaScript code?
<script>
var msgs=new Array("Hello","Hey","Morning!");
for (i=0;i<msgs.length;i++){
document.write(msgs[i] + " | ");
}
</script>
A. Hello | Hey | Morning! |
B. Hello | Hey |
C. ValueError
D. TypeError
Which JavaScript method is used to call a function (a callback
function) once for each array element?
A. for()
B. traverse()
C. forAll()
D. foreach()
Which JavaScript method is used to create a new array with
array elements that passes a test?
A. forEach()
B. map()
C. forMap()
D. filter()
What will be the output of the following JavaScript code?
<script>
let str1 = new String("IncludeHelp!");
let str2 = new String("IncludeHelp!");
document.getElementById("test").innerHTML = (str1==str2);
</script>
A. true
B. false
C. True
D. False
What will be the output of the following JavaScript code?
<script>
let str = "IncludeHelp";
document.getElementById("test").innerHTML = str.length;
</script>
A. 11
B. 12
C. ValueError
D. SyntaxError
JavaScript types are _____.
A. Static
B. Dynamic
What is the output of the following JavaScript code (let
example)?
<script>
let a = 10;
let a = 0;
</script>
A. 10
B. 0
C. SyntaxError
D. TypeError
What is the output of the following JavaScript code?
<script>
var a;
document.getElementById("demo").innerHTML = a+1;
</script>
A. 0
B. undefined
C. 1
D. NaN
What will be the value of VALUE?
<script>
const VALUE = 10;
VALUE = 20;
</script>
A. 10
B. 20
C. ValueError
D. TypeError
In JavaScript, multi-line comments start with __ and end with
___.
A. /* and */
B. <!—and -->
C. ## and ##
D. // and //