-1

The point of confusion is - when we check the type of array or object using typeof get the return value as Object. So what's the main difference between them.

Mohan Rajput
  • 634
  • 9
  • 21
Suyash Madhav
  • 49
  • 1
  • 2
  • 9

1 Answers1

0

You can check using constructor.name

const myArr = []
const myObj = {}


console.log(`myArr is an ${myArr.constructor.name}`)
console.log(`my Obj is an ${myObj.constructor.name}`)
ksav
  • 20,015
  • 6
  • 46
  • 66