Skip to content

Commit

Permalink
Adding arguments detection to Object.keys, from https://github.com/lj…
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Mar 26, 2014
1 parent 28ec1ce commit 2dd3abf
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions es5-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -674,10 +674,27 @@ if (!Object.keys) {
"propertyIsEnumerable",
"constructor"
],
dontEnumsLength = dontEnums.length;
dontEnumsLength = dontEnums.length,
isFunction = function isFunction(value) {
return _toString(value) === '[object Function]';
},
isArguments = function isArguments(value) {
var str = _toString(value);
var isArguments = str === '[object Arguments]';
if (!isArguments) {
isArguments = !Array.isArray(str)
&& value !== null
&& typeof value === 'object'
&& typeof value.length === 'number'
&& value.length >= 0
&& isFunction(value.callee);
}
return isArguments;
};

Object.keys = function keys(object) {
var isFunction = _toString(object) === '[object Function]',
var isFunction = isFunction(object),

This comment has been minimized.

Copy link
@jdalton

jdalton Mar 31, 2014

Contributor

isFunction = isFunction(...) is an error.

isArguments = isArguments(object),

This comment has been minimized.

Copy link
@jdalton

jdalton Mar 31, 2014

Contributor

isArguments = isArguments is in the same boat and never used in the rest of the function body.

isObject = object !== null && typeof object === 'object';

if (!isObject && !isFunction) {
Expand Down

3 comments on commit 2dd3abf

@michaelficarra
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why didn't this commit go through the review process?

@ljharb
Copy link
Member Author

@ljharb ljharb commented on 2dd3abf Mar 31, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I directly committed it. I'll fix these issues.

@ljharb
Copy link
Member Author

@ljharb ljharb commented on 2dd3abf Mar 31, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fixed in a7fe7ad. I've filed #216 to add behavior for the arguments object.

Please sign in to comment.