Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitef9153f

Browse files
substackljharb
substack
authored andcommitted
isConstructorOrProto adapted from PR
1 parent36ac5d0 commitef9153f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

‎index.js‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ function isNumber(x) {
66
return(/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/).test(x);
77
}
88

9+
functionisConstructorOrProto(obj,key){
10+
returnkey==='constructor'&&(typeofobj[key]==='function'||key==='__proto__');
11+
}
12+
913
functionhasKey(obj,keys){
1014
varo=obj;
1115
keys.slice(0,-1).forEach(function(key){
@@ -21,7 +25,9 @@ function setKey(obj, keys, value) {
2125
varkey;
2226
for(vari=0;i<keys.length-1;i++){
2327
key=keys[i];
24-
if(key==='__proto__'){return;}
28+
if(key==='__proto__'||isConstructorOrProto(o,key)){
29+
return;
30+
}
2531
if(o[key]===undefined){o[key]={};}
2632
if(
2733
o[key]===Object.prototype

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp