Javascript Prt 2 Flashcards
1
Q
What's the output? function sum(a, b) { return a + b; }
sum(1, "2"); A: NaN B: TypeError C: "12" D: 3
A
C: “12”
2
Q
What will the following Javascript code output? var a = []; a[0] = 'test'; a[3] = 9; alert( a );
A
Array: [‘test’, , , 9]
3
Q
What does the following Javascript output? var a = 1/0; a. Infinity b. NaN c. Error d. 0
A
a. Infinity
4
Q
What does the following Javascript output (and why)? // Self invoking function (function () { var abc = "Hello"; // I will invoke myself })(); alert( abc );
A
Error (no output)
As the abc variable is out of scope.
5
Q
Is JavaScript a subject of Java?
A
No it is not.
6
Q
Name 3 JavaScript Value Types
A
Undefined Null Booleans Number Strings Symbols (Objects)
7
Q
var x = 12; What value type is it in JavaScript?
A
Number.
8
Q
What does the following Javascript output? var myvalue; alert( myvalue ); a. Infinity b. NaN c. Error d. Undefined
A
d. Undefined
undefined value possessed by unassigned variables
9
Q
what would be the output of NaN == NaN?
A
False, NaN is not equal it it self.
10
Q
In JavaScript, what does NaN stand for?
A
Not a Number.
11
Q
In JavaScript, what is the return of parseInt(“06”); ?
A
6
12
Q
What does the following Javascript output? var a = 1/"2"; var b = a + 1; alert( b ); a. Infinity b. NaN c. Error d. None of the above
A
d. None of the above
13
Q
What does the following Javascript output? var a = "cat" * 2 alert( a ); a. Infinity b. NaN c. Error d. None of the above
A
b. NaN
14
Q
In JavaScript, what is the difference between Null and Undefined.
A
Null has no value.
Undefined is not even a value.
15
Q
In JavaScript, what is the output of “0” == false;
A
true;