最小化数组变量的声明

时间:2019-05-17 08:28:58

标签: javascript

我必须声明一些变量,并希望缩小代码。这是我当前的代码:

let a = [0,0,0,0,0,0,0,0,0,0];
let b = [0,0,0,0,0,0,0,0,0,0];
let c = [0,0,0,0,0,0,0,0,0,0];

有没有办法减少代码?

我尝试了以下操作,但不起作用:

  let a = b = c = [0,0,0,0,0,0,0,0,0,0];

  let a, b, c = [0,0,0,0,0,0,0,0,0,0];

  let a = [0,0,0,0,0,0,0,0,0,0];
  let b = a; // b becomes a pointer to "a"
  let c = a;

0 个答案:

没有答案