Skip to content

Instantly share code, notes, and snippets.

@mmis1000
Created July 18, 2019 05:52
Show Gist options
  • Save mmis1000/a9db1df6de2902edd9b17047459b2022 to your computer and use it in GitHub Desktop.
Save mmis1000/a9db1df6de2902edd9b17047459b2022 to your computer and use it in GitHub Desktop.
Detect v8 js engine using undefined behavior of v8
var isChrome = (() => {
with ({}) {
var a = new ArrayBuffer(16)
new Float64Array(a)[0] = NaN
new Uint8Array(a)[0] = 1
new Float64Array(a)[1] = new Float64Array(a)[0]
return new Uint8Array(a)[8] === 1
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment