Skip to content

Commit

Permalink
fix: get all keys (including enumerable and unenumerable properties).…
Browse files Browse the repository at this point in the history
… (issue #327)
  • Loading branch information
Maizify committed Jan 14, 2021
1 parent 8d8efa8 commit 53e070f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dist/vconsole.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/core/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ class VConsole {
that.switchPos.hasMoved = false;
});
$.bind($switch, 'touchend', function(e) {
console.log(e);
if (!that.switchPos.hasMoved) {
return;
}
Expand Down
19 changes: 12 additions & 7 deletions src/lib/tool.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,19 @@ export function getObjAllKeys(obj) {
if (!isObject(obj) && !isArray(obj)) {
return [];
}
if (isArray(obj)) {
const m = [];
obj.forEach((_, index) => {
m.push(index)
});
return m;
// if (isArray(obj)) {
// const m = [];
// obj.forEach((_, index) => {
// m.push(index)
// });
// return m;
// }
// return Object.getOwnPropertyNames(obj).sort();
const keys = [];
for (let k in obj) {
keys.push(k);
}
return Object.getOwnPropertyNames(obj).sort();
return keys.sort();
}

/**
Expand Down

0 comments on commit 53e070f

Please sign in to comment.