0

I don't understand why the first result is true and the second is false in this code:

let x = new String("testing value")
let y = 'testing value with y'
console.log(x instanceof Object); // gives true
console.log(y instanceof Object); // gives false
  • Because you did not specify `y` as an object when it was declared. https://stackoverflow.com/questions/2449254/what-is-the-instanceof-operator-in-javascript – Sarah Oct 13 '22 at 21:00

0 Answers0