1

im having a hard time understanding why type of Object and even String and other data types is a function, is it a function constructor ?

console.log(typeof Object);
// function
pilchard
  • 12,414
  • 5
  • 11
  • 23
  • 4
    "*Is it a constructor?*" - yes. Try calling it! – Bergi Oct 24 '21 at 22:28
  • 2
    see: [Object() constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/Object), [String() constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/String) – pilchard Oct 24 '21 at 22:31

1 Answers1

1

Try using this syntax instead....

console.log(typeof {}); // "object"
console.log(typeof new Object); // "object"

All object type constructor functions, when initiated with the new keyword will always have a type of “object”.