const obj = {
true: 'a',
['true']: 'b',
[true]: 'c',
};
const result = Object.keys(obj).length;
会发生什么?
const foo = 'bar';
const obj = {
foo: 'a',
[foo]: 'b',
};
const result = obj.foo;
会发生什么?
const foo = 'bar';
const obj = {
foo: 'a',
[foo]: 'b',
};
const result = obj.bar;
会发生什么?
const foo = 'bar';
const obj = {
foo: 'a',
[foo]: 'b',
};
const result = obj[foo];
会发生什么?
const foo = 'bar';
const obj = {
foo: 'a',
[foo]: 'b',
};
const result = obj[bar];
会发生什么?
const foo = 'bar';
const obj = {
foo: 'a',
[foo]: 'b',
};
const result = obj['foo'];
会发生什么?
const foo = 'bar';
const obj = {
foo: 'a',
[foo]: 'b',
};
const result = obj['bar'];
会发生什么?
const symbol1 = Symbol('symbol1');
const symbol2 = Symbol('symbol2');
const obj = {
name1: 0,
[symbol1]: 0,
};
Object.defineProperties(obj, {
name2: { enumerable: false, value: 0 },
[symbol2]: { enumerable: false, value: 0 },
});
const result = Object.keys(obj);
结果是什么?
const symbol1 = Symbol('symbol1');
const symbol2 = Symbol('symbol2');
const obj = {
name1: 0,
[symbol1]: 0,
};
Object.defineProperties(obj, {
name2: { enumerable: false, value: 0 },
[symbol2]: { enumerable: false, value: 0 },
});
const result = Reflect.ownKeys(obj);
结果是什么?
const symbol1 = Symbol('symbol1');
const symbol2 = Symbol('symbol2');
const obj = {
name1: 0,
[symbol1]: 0,
};
Object.defineProperties(obj, {
name2: { enumerable: false, value: 0 },
[symbol2]: { enumerable: false, value: 0 },
});
const result = Object.getOwnPropertyNames(obj);
结果是什么?
const symbol1 = Symbol('symbol1');
const symbol2 = Symbol('symbol2');
const obj = {
name1: 0,
[symbol1]: 0,
};
Object.defineProperties(obj, {
name2: { enumerable: false, value: 0 },
[symbol2]: { enumerable: false, value: 0 },
});
const result = Object.getOwnPropertySymbols(obj);
结果是什么?
const jane = {
name: 'Jane',
hello() {
return `Hello ${this.name}!`;
},
};
const func = jane.hello;
以下哪种调用 obj.hello
的方式有效?
const proto = { prop: 'a' };
const obj = Object.create(proto);
obj.prop = 'b';
proto.prop
是什么?
const proto = {
foo: 'p',
logFoo() {
console.log(this.foo);
}
};
const obj = {
foo: 'o',
__proto__: proto,
};
proto.logFoo.call(obj);
proto.logFoo.call(proto);
会发生什么?