我不明白,我在互联网上找不到字符串是如何工作的var exp = (o>4), o = o%5, str = pangrams[+exp][o];
。解释 - 谁知道,以及如何谷歌?
var pangrams = [
// not pangrams:
[
"This isn't a pangram!",
"abcdefghijklmopqrstuvwxyz ",
"aaaaaaaaaaaaaaaaaaaaaaaaaa",
"Detect Pangram",
"A pangram is a sentence that contains every single letter of the alphabet at least once."
],
// pangrams:
[
"Cwm fjord bank glyphs vext quiz",
"Pack my box with five dozen liquor jugs.",
"How quickly daft jumping zebras vex.",
"ABCD45EFGH,IJK,LMNOPQR56STUVW3XYZ",
"AbCdEfGhIjKlM zYxWvUtSrQpOn"
]
];
[0,1,2,3,4,5,6,7,8,9].forEach(function(o){
var exp = (o>4), o = o%5, str = pangrams[+exp][o]; // как работает дання строка и что она делает?
console.log(str);
});
exp = (o>4)
- exp 返回真或假,取决于 o 是否大于 4。o = o%5
- 计算除法的余数。str = pangrams[+exp][o]
- 将exp转换为数值0或1,然后pangrams
根据指定的键exp和o将数组元素返回给str。