单选题:
1,
(function(callback){ city = {name: 'hangzhou'}; callback(city); })(function(obj){ obj.name = "shanghai"; obj = {name: "beijing"}; }); console.log(city.name); //"shanghai"
2,
const {defineProperty, freeze} = Object; const run = fn => { try { fn(); } catch(e){ } } Object.prototype.name = 'Anonymous'; let user = { name: 'James', } const constUser = { name:'Musker' } run(() => defineProperty(user, 'name', { writable: false, value:'Basin', })); run(() => user.name = 'Lily') run(() => user = {name:'Helios'}) run(() => user = constUser) run(() => user.name = 'Peggy') run(() => user = freeze({name:'Karmen'})) run(() => user.name = 'Vienna') run(() => delete user.name) console.log(user.name); // "Karmen"