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”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
What will the following Javascript code output?
var a = [];
a[0] = 'test';
a[3] = 9;
alert( a );
A

Array: [‘test’, , , 9]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
What does the following Javascript output?
var a = 1/0;
    a. Infinity
    b. NaN
    c. Error
    d. 0
A

a. Infinity

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Is JavaScript a subject of Java?

A

No it is not.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Name 3 JavaScript Value Types

A
Undefined
    Null
    Booleans
    Number
    Strings
    Symbols (Objects)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

var x = 12; What value type is it in JavaScript?

A

Number.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

what would be the output of NaN == NaN?

A

False, NaN is not equal it it self.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

In JavaScript, what does NaN stand for?

A

Not a Number.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

In JavaScript, what is the return of parseInt(“06”); ?

A

6

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

In JavaScript, what is the difference between Null and Undefined.

A

Null has no value.

Undefined is not even a value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

In JavaScript, what is the output of “0” == false;

A

true;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly