js with All In One
js with All In One
不推荐,要废弃 👎

function f(x, o) {
with (o) {
console.log(x);
}
}
function f(foo, values) {
with (foo) {
console.log(values);
}
}
var a, x, y;
var r = 10;
with (Math) {
a = PI * r * r;
x = r * cos(PI);
y = r * sin(PI / 2);
}
refs
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/with
https://2ality.com/2011/06/with-statement.html
https://stackoverflow.com/questions/1931186/with-keyword-in-javascript
https://stackoverflow.com/questions/61552/are-there-legitimate-uses-for-javascripts-with-statement
©xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/13857625.html
未经授权禁止转载,违者必究!

浙公网安备 33010602011771号