【发布时间】:2018-01-31 20:45:07
【问题描述】:
在 perl 中,我们可以使用 qw 或 quote word 声明数组,使每个单词都被放入单独的数组单元格中。
例如。
my @arr= qw( hello
world)
否则你需要引用每个单词 例如
my @arr = ("hello" , "word");
在javascript中是否有类似的东西,因为有时它需要大量的格式来简单地声明数组。
【问题讨论】:
-
使用数组字面量?
-
const arr = ["hello", "world"];? -
替代你可以使用一个标记的模板字符串: const s = v => v; const arr = s`你好${}世界`; ;)
标签: javascript arrays node.js perl