Skip to content

Instantly share code, notes, and snippets.

@cvazac
Created April 26, 2017 16:41
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 cvazac/c1d1925663e323e318b93c4e7cdb1557 to your computer and use it in GitHub Desktop.
Save cvazac/c1d1925663e323e318b93c4e7cdb1557 to your computer and use it in GitHub Desktop.
checkNatives
function isNativeFunction(fn) {
return typeof fn === 'function' && fn.toString && !fn.hasOwnProperty('toString') &&
/\[native code\]/.test(String(fn))
}
function checkNatives(fns) {
var results = []
for (var i = 0; i < fns.length; i++) {
results[i] = {
fn: fns[i],
native: isNativeFunction(fns[i])
}
}
return results
}
console.info(checkNatives([setTimeout, XMLHttpRequest]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment