Array And Function - Study Mode

[#26] Consider the following code snippet : var tensquared = ( function ( x ) {return x * x

}( 10 ))

Will the above code work ?
Correct Answer

(A) Yes, perfectly

Explanation

Solution: Function name is optional for functions defined as expressions. Function expressions are sometimes defined and immediately invoked.

[#27] Consider the following code snippet : var string2Num =parseInt (" 123xyz ")

The result for the above code snippet would be :
Correct Answer

(B) 123xyz

Explanation

Solution: The parseInt() function returns the first integer contained in the string or 0 if the string does not begin with an integer.

[#28] If you have a function f and an object o, you can define a method named m of o with
Correct Answer

(A) o.m=m.f

Explanation

Solution: A method is nothing more than a JavaScript function that is stored in a property of an object. If you have a function f and an object o, you can define a method named m of o with the following line: o.m = f

[#29] For the below mentioned code snippet: var o = new Object ()

The equivalent statement is:
Correct Answer

(C) var o= new Object

Explanation

Solution: You can always omit a pair of empty parentheses in a constructor invocation.

[#30] What is the difference between the two lines given below ? !!( obj1 && obj2 )

( obj1 && obj2 )

Correct Answer

(D) The first line results in a real boolean value whereas the second line merely checks for the existence of the objects