getTag

getTag returns string representation of Object.We may not expect the right value for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6 We expect
  1. DataView - [object DataView]
  2. Map - [object Map]
  3. Promise - [object Promise]
  4. Set - [object Set]
  5. WeakMap - [object WeakMap]

In all the above cases where we don't get the value as expected, we derive at the object's type using its constructor.
console.log(`${DataView}`)
const o = new DataView(new ArrayBuffer(1))
console.log("Based on o.constructor")
console.log(`${o.constructor}`)
Output:
function DataView() { [native code] }
Based on o.constructor
function DataView() { [native code] }

Comments

Popular posts from this blog

baseToNumber

baseToString