在进行js的书写中,对于常见的if,for,while是可以简写,省略花括号{}的:

var a = 10,b = 20;
/**
 * if 简写
 */
if(a > b) console.log('a大');
if(a < b) console.log('b大');
/**/
if(a > b) console.log('a大');
else console.log('b大');

/**
 * for简写
 */
for(var i=0; i<10; ++i) console.log(i);

/**
 * while简写
 */
while (i > 10) console.log(i);

 

相关文章:

  • 2021-09-28
  • 2022-12-23
  • 2022-01-02
  • 2022-02-07
  • 2022-02-07
  • 2022-01-06
猜你喜欢
  • 2022-02-07
  • 2022-12-23
  • 2022-12-23
  • 2022-02-07
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案