JavaScript Developer Questionnaire
1. Examine this script example.
var r = undefined ;
a = b = c = 20 ;
n = i = r ;
1.1 What will be the value of b after its execution?
2. Describe each part of a for loop structure.
3. Examine this script example.
for ( i = 0 ; i < n ; i ++ ) {
b = i ;
}
3.1 Explain at least 3 things wrong with it.
3.2 What will be the value of b?
4. After the following code has run what will be the value of x?
var x = true && true && true && false ;
5. Consider the following scipt. After running it:
var x = 0 ;
function multiply ( a , b ) {
var x = a * b ;
return x ;
}
var z = multiply ( 20 , 10 ) ;
5.1 What will be the value of x?
5.2 What will be the value of z?
6. Consider the following script. After running it:
( function ( ) {
b = 20 ;
var a = 10 * b ;
return a ;
} ) ( ) ;
console . log ( b ) ;
console . log ( a ) ;
6.1 what will be the printed value of b?
6.2 What will be the printed value of a?
7. What will be the value of a?
8. What will be the value of a['foo']?
var a = { bar : 10 , baz : 20 , foo : 40 } ;
a . foo += a . bar ;
9. What will be the value of a[3]?
var a = "I ran all the way home" ;
10. What will be the value of b[3]?
var b = "I ran all the way home" . split ( ' ' ) ;
11. What will be the value of m?
var m = / t e s t / . test ( "I know this is a test" ) ;
12. Consider the following script. After running it:
Object . prototype . mush = function ( ) {
var b = 0 , c = [ ] ;
if ( this instanceof Array ) {
b = this . reduce ( function ( s , i ) { return s + i ; } ) ;
c = this . map ( function ( i ) { return b ; } ) ;
}
return c ;
}
a = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 ] ;
a . mush ( ) ;
b = a [ 2 ] ;
12.1 What will be the value of b?
12.2 What will be the value of a.mush()[2]?
12.3 What will be the value of b == a.mush()[2]