太深奥了,may be only:with (o={a: 10, b: 20, "3": 30}) { alert(a); alert(b); alert(o[3]); }ps: JavaScript code that uses with is difficult to optimize and may therefore run more slowly than the equivalent code written without the with statement.So it is recommended that you avoid the with statement.
<script> var o = {a: 10, b: 20, "3": 30}; with (o) { alert(a); alert(b); alert(o["3"]); // ???? 如何访问"3" } </script>
那个属性标示符也可以是数字?
这个还真没试过。
with ({a: 10, b: 20, "3": 30}) {
alert(this.a); //undefined
}
說明this并不是指的這個匿名對象
關注中
alert(a);
alert(b);
alert(o[3]);
}ps: JavaScript code that uses with is difficult to optimize and may therefore run more slowly than the equivalent code written without the with statement.So it is recommended that you avoid the with statement.
var o = {a: 10, b: 20, "3": 30};
with (o) {
alert(a);
alert(b);
alert(o["3"]); // ???? 如何访问"3"
}
</script>
alert(a);
alert(b);
alert(c()["3"]); // ???? 如何访问"3"
}
with ({a: 10, b: 20, "3": 30}) {
alert(a);
alert(b);
alert(valueOf()["3"]);
}
with ({a: 10, b: 20, 3: 30}) {
alert(a);
alert(b);
alert(valueOf()[3]);
}
这样也行~这个东东很强大~