DEV Community

Gerardo
Gerardo

Posted on

Do you really know JS?

Hi!, this is my first post and I wanted to make it a little and simple javascript quiz but I wont give you the answers, the idea is that you put your answers in the comments and discussed which ones are correct and which are not, so let's begin!

1.- What is the result of this expression? (or multiple ones)

                 ["1", "2", "3"].map(parseInt)

a) ["1","2", "3"]
b) [1,2,3]
c) [1, NaN, NaN]
d) other (give your answer)

2.- What is the result of this expression? (or multiple ones)

                 [typeof null, null instanceof Object]

a) ["object", true]
b) ["object", false]
c) ["object", null]
d) other (give your answer)

3.- What is the result of this expression? (or multiple ones)

                  var x = [].reverse;
                  x();

a) window
b) other
c) undefined
d) true

4.- What is the result of this expression? (or multiple ones)

                   2 == [[[2]]]

a) false
b) true
c) error
d) undefined

5.- What is the result of this expression? (or multiple ones)

                   var a = /123/,
                   b = /123/;
                   a == b
                   a === b

a) true, true
b) true, false
c) false, true
d) other

6.- What is the result of this expression? (or multiple ones)

          var a = {}, b = Object.prototype;
          [a.prototype === b, Object.getPrototypeOf(a) === b]

a) [true, false]
b) [true, true]
c) [false, false]
d) none of the above

Top comments (8)

Collapse
 
strdr4605 profile image
Dragoș Străinu • Edited

I think 4 out of 6 is a good score!

Bonus task:
Make a function that satisfies these conditions!

fn(1)(2)(3)(4) == 10 // true
fn(1)(2) == 3 // true
fn(1)(0)(0)(0)(0)(3) == 4 // true
fn(1) == 1 // true
Collapse
 
clementdeb profile image
clementDeb

hello, thanks for the question, could you explain why the 5 is false, false ? please

Collapse
 
josemunoz profile image
José Muñoz

because you're comparing references, not their values.

SO Thread: stackoverflow.com/questions/110327...

Collapse
 
clementdeb profile image
clementDeb

because they are regex which means object. cheers

Collapse
 
wilsilva profile image
William Silva

Why error with these expressions?

Collapse
 
pavandkvrk profile image
pavandkvrk • Edited

Q1 : B
I think Q2 : A

Collapse
 
inventivemejo profile image
inventivemejo

I'm new to this website, and not able to select options or locate ans.
Would somebody help me to find answers?

Collapse
 
jgaguiar16 profile image
Gerardo

You can't select the options, my idea was that you paste your answers here in the comment section and discuss them with the community haha