是不是可以在javascript中使用类似“with”的东西——比如......
var test = {
vars: {
customer: {
Name: '',
Address: '',
Town: ''
}
},
Init: function () {
with this.vars.customer {
Name = 'Mike';
Address = 'Union Square 2';
Town = 'San Francisco';
}
}
}
?
谢谢
更新:
我不喜欢这种语法:
Init: function () {
this.vars.customer.Name = 'Mike';
this.vars.customer.Address = 'Union Square 2';
this.vars.customer.Town = 'San Francisco';
}
很乱