CyanSalt / notebook

3 stars 0 forks source link

JS 属性读写题 #24

Open CyanSalt opened 4 years ago

CyanSalt commented 4 years ago

path: js-property-question


function getObject() {}
function getKey() {}

let obj = getObject();
let key = getKey();

let valueA = obj[key];
let valueB = 3;
obj[key] = valueB
let valueC = obj[key];

assert(isNaN(valueA)); // false
assert(isNaN(valueC)); // false
assert(valueA === valueB); // false
assert(valueB === valueC); // false
assert(valueA === valueC); // false
CyanSalt commented 4 years ago
function getObject() {
  return localStorage;
}
function getKey() {
  return 'length';
}