标签:语句 The mat 转换 amp 条件语句 trie UNC oca
var example = "potato potato";
console.log(example.replace(/pot/, "tom")); //替换一次
console.log(example.replace(/pot/g, "tom")); //全局替换
var entries = [1, 2, 2, 3, 4, 5, 6, 6, 7, 7, 8, 4, 2, 1]
var unique_entries = [...new Set(entries)]; // 创建一个具有唯一值的新数组
the_string = "123";
console.log(+the_string);// 123
the_string = "hello";
console.log(+the_string); //NAN
var my_list = [1, 2, 3, 4, 5, 6, 7, 8, 9];
console.log(my_list.sort(function() {
return Math.random() - 0.5
}));
var entries = [1, [2, 5], [6, 7], 9];
var flat_entries = [].concat(...entries);
if (available) {
addToCart();
} 可以替换成
available && addToCart()
const dynamic = ‘flavour‘;
var item = {
name: ‘Coke‘,
[dynamic]: ‘Cherry‘
}
console.log(item); // { name: "Coke", flavour: "Cherry" }
var entries = [1, 2, 3, 4, 5, 6, 7];
entries.length = 4;
console.log(entries); // [1, 2, 3, 4]
标签:语句 The mat 转换 amp 条件语句 trie UNC oca
原文地址:https://www.cnblogs.com/moneyss/p/12024368.html