add if (!value.hasOwnProperty(vKey)) continue; that occurred bugs!#236
add if (!value.hasOwnProperty(vKey)) continue; that occurred bugs!#236XadillaX wants to merge 1 commit into
Conversation
2739d8e to
8888021
Compare
There was a problem hiding this comment.
Sry, this is because of my JSHint.
#the never used variables#
There was a problem hiding this comment.
sure, but re-defining a scoped undefined variable actually makes checking against undefined safe as you can override the global undefined variable with things.
There was a problem hiding this comment.
I think the redefining undefined part is obsolete in node and other modern runtimes:
> undefined = 'foo'
'foo'
> undefined
undefined
|
Some minor comments but LGTM. |
|
@ronkorving @3rd-Eden So you both prefer to use |
|
I found another problem when I use If the object is This error makes TypeError: Cannot convert undefined or null to object
at Function.keys (native)
at Object.merge (/Users/XadillaX/code/node/node-memcached/lib/utils.js:113:10)
at new Client (/Users/XadillaX/code/node/node-memcached/lib/memcached.js:58:9)
at Context.<anonymous> (/Users/XadillaX/code/node/node-memcached/test/memcached-touch.test.js:21:21)
at Test.Runnable.run (/usr/local/lib/node_modules/mocha/lib/runnable.js:217:15)
at Runner.runTest (/usr/local/lib/node_modules/mocha/lib/runner.js:373:10)
at /usr/local/lib/node_modules/mocha/lib/runner.js:451:12
at next (/usr/local/lib/node_modules/mocha/lib/runner.js:298:14)
at /usr/local/lib/node_modules/mocha/lib/runner.js:308:7
at next (/usr/local/lib/node_modules/mocha/lib/runner.js:246:23)
at Immediate._onImmediate (/usr/local/lib/node_modules/mocha/lib/runner.js:275:5)
at processImmediate [as _immediateCallback] (timers.js:321:17)So I think we still should use |
|
Correct, Object.keys breaks on non-objects. A simple truthy check would address that, right? That's my preferred style. But I suggest you go with whatever style @3rd-Eden prefers. if (obj) {
var keys = Object.keys(obj);
} |
|
But doing a If the code fails with |
Before patching this patch, some functions attached to the object will be parsed and thrown errors!
For an example:
The result will be
abc- this is not my expected result!In your
for ... inof util.js:We should ignore
abcthis extended function.