Skip to content

Instantly share code, notes, and snippets.

@DoctorDerek
Created November 17, 2020 19:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DoctorDerek/3110d41754b2413600f3a2798c2738fc to your computer and use it in GitHub Desktop.
Save DoctorDerek/3110d41754b2413600f3a2798c2738fc to your computer and use it in GitHub Desktop.
// NOTE: instanceof won't work inside iframes
const myObject = {}
console.log(myObject instanceof Object) // true
console.log(myObject instanceof Array) // false
const myArray = []
console.log(myArray instanceof Object) // true
console.log(myArray instanceof Array) // true
const myNull = null
console.log(myNull instanceof Object) // false
console.log(myNull instanceof Array) // false
const myDate = new Date()
console.log(myDate instanceof Object) // true
console.log(myDate instanceof Array) // false
console.log(myDate instanceof Date) // true
const myRegExp = /howdy/
console.log(myRegExp instanceof Object) // true
console.log(myRegExp instanceof Array) // false
console.log(myRegExp instanceof RegExp) // true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment