/  JavaScript-Functions-Quiz

This Quiz contains totally 10 Questions each carry 1 point for you.

1. Do functions in JavaScript necessarily return a value?
It is mandatory
Not necessary
Few functions return values by default
some functions do not return any value

Correct!

Wrong!

2. Will the following JavaScript code work?

var tensquared = (function(x) {return x*x;}(10));
Yes, perfectly
Error
Exception will be thrown
Memory leak

Correct!

Wrong!

3. What will be the output of the following JavaScript code?

var string2Num=parseInt("123xyz");
123
123xyz
Exception
NaN

Correct!

Wrong!

4. The one-liner code that concatenates all strings passed into a function is
function concatenate() { return String.prototype.concat('', arguments); }
function concatenate() { return String.prototype.apply('', arguments); }
function concatenate() { return String.concat.apply('', arguments); }
function concatenate() { return String.prototype.concat.apply('', arguments); }

Correct!

Wrong!

5. Which of the following function of Number object returns the number's value?
toString()
valueOf()
toLocaleString()
toPrecision()

Correct!

Wrong!

6.  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]()
9
0
10
12

Correct!

Wrong!

7. What will be the output of the following JavaScript code?
var add=new Function("num1","num2","return num1+num2");
document.writeln(add(2,5));
2
5
error
7

Correct!

Wrong!

8. What will be the state stored in d in the following JavaScript code?

var c = counter(), d = counter();

c.count()

d.count()

c.reset()

c.count()

d.count()
1
0
NULL
Undefined

Correct!

Wrong!

9. If you have a function f and an object o, you can define a method named m of o with
o.m=m.f;
o.m=f;
o=f.m;
o=f;

Correct!

Wrong!

10. What will be the equivalent statement of the following JavaScript statement?

var o = new Object();
var o = Object();
var o;
var o= new Object;
Object o=new Object();

Correct!

Wrong!

Share the quiz to show your results !

Subscribe to see your results

Ignore & go to results

JavaScript-Functions-Quiz

You got %%score%% of %%total%% right

%%description%%

%%description%%

Where to go ?

Quizzes

Loading...