-
-
Save SiZapPaaiGwat/f254afb6998dfcddb0d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Cross-browser but not absolutely strong. | |
function isArguments( obj ) { | |
return typeof obj === "object" && ( "callee" in obj ) && typeof obj.length === "number"; | |
} | |
// Ideally strong, but broken on Opera... | |
var isArguments = (function( undefined ) { | |
var toStr = ({}).toString, | |
returnTrue = function() { | |
// To be sure it will not be inlined (future engines). | |
return arguments !== undefined; | |
}, | |
test = function( obj ) { | |
return obj != null && toStr.call( obj ) === "[object Arguments]"; | |
}; | |
return test( arguments ) ? test : | |
function( obj ) { | |
// Using "in" works in strict mode too. | |
if ( obj != null && "callee" in obj ) { | |
try { | |
return returnTrue.apply( this, obj ); | |
} catch (e) {} | |
} | |
return false; | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment