不要糊弄分支预测器
为了避免流水线阻塞,最好是没有任何分支结构。遗憾的是编程中不可能不用分支,退而求其次,我们能做的是尽量减少分支。一个经典的减少分支的办法是用位操作取代条件表达式,像这样:
const int maxValue = 16;
if (x >= maxValue) x = 0;
// 等同于
x =
1 、concat() 数组、字符串合并。
let a = [1,2,3]
let b = [4,5,6]
a.concat(b) // [1, 2, 3, 4, 5, 6]
let c = 'hello '
let d = 'world'
c.concat(d) // 'hello world'
2、 at() 数组、字符串、类数组中添加.at()方法at()支持正索引和负索引,获取其指定位