Lodash官网地址:https://www.lodashjs.com/
一 、 数组乱序排列
JS 代码如下:
<script src
="./lodash.html"></script
>
<script
>
var a
= [1, 2, 3, 4, 5, 6, 7]
var b
= _
.shuffle(a
)
console
.log(b
);
</script
>
二 、浅拷贝 、深拷贝
var objects
= [{ 'a': 1 }, { 'b': 2 }];
var shallow
= _
.clone(objects
);
console
.log(shallow
[0] === objects
[0]);
var objects
= [{ 'a': 1 }, { 'b': 2 }];
var deep
= _
.cloneDeep(objects
);
console
.log(deep
[0] === objects
[0]);
转载请注明原文地址:https://tech.qufami.com/read-16573.html