#Quiz:
-
What’s the result of:
console.log(f()); function f() { return 1; }
Answers:
- null
- undefined
- 1
- error
-
How do these differ?
function foo() {} // versus var foo = function() {};
-
What’s the result of:
function f() { var a = 5; return new Function('b', 'return a + b'); } consoe.log( f()(1) );
Answers:
- 1
- 6
- undefined
- NaN
- error
-
What’s the result of:
var f = function(x) { console.log(x) } (function() { f(1); }())
Answers:
- nothing
- 1
- error
- depends on browser
-
What’s the result of:
function() { if (true) { var a = 5; } console.log(a); }
Answers:
- nothing
- 5
- error
- depends on browser
-
What’s the result of:
function f(x, y) { x = 10; console.log( arguments[0], arguments[1] ); } f();
Answers:
- 10, null
- 10, undefined
- undefined, undefined
- 10, NaN
-
What’s the result of:
function a(x) { return x * 2; } var a; console.log(a);
Answers:
- error
- 2
- undefined
- body of function
-
What’s the result of:
(function f() { function f() { return 1; } return f(); function f() { return 2; } })();
Answers:
- 1
- 2
- undefined
- depends on browser
-
What’s the result of:
(function() { return typeof arguments; })();
Answers:
- 'object'
- 'array'
- 'arguments'
- 'undefined'
-
What’s the result of:
var f = function g() { return 'test'; }; console.log( typeof g() );
Answers:
- string
- undefined
- function
- error
-
What’s the result of:
(function() { var kittySays = 'Meow'; })(); console.log(kittySays);
Answers:
- 'Meow'
- undefined
- null
- error
-
What’s the result of:
console.log (f()); var f = function () { return 1; };
Answers:
- null
- undefined
- 1
- error
-
What’s the result of:
var x = 1; (function() { console.log(x); return x; var x = 2; })();
Answers:
- 2
- undefined
- 1
- error