xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

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 发布文章使用:只允许注册用户才可以访问!


posted @ 2020-10-22 13:01  xgqfrms  阅读(99)  评论(0)    收藏  举报