201706180310_《 Javascript (ES6)给变量一个hash串》
Posted Stay foolish, stay hungry!
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了201706180310_《 Javascript (ES6)给变量一个hash串》相关的知识,希望对你有一定的参考价值。
(() => { //UUID Fn-1 S4 = () => { return (((1+Math.random())*0x10000)|0).toString(16).substring(1); }; //UUID Fn-2 guid = () => { let me = this; return (me.S4()+me.S4()+"-"+me.S4()+"-"+me.S4()+"-"+me.S4()+"-"+me.S4()+me.S4()+me.S4()); }; let oUuid = guid(); let oArr = [‘Apple‘,‘Banana‘,‘Orange‘,‘Cheer‘]; oArr.forEach((v,i,a) => { this.v = `${v}-${guid()}`; console.log(this.v); }); })(); // Apple-2b51f63b-45c8-070f-e3aa-71184a90eb3f //Banana-e1ccf286-9d65-e7a0-0949-8bba1077554a // Orange-a2e973fb-1c6f-6a82-c57d-fb7ae4143a1e //Cheer-23d85cd0-3006-c1d3-fec0-79ba5458e5f6
以上是关于201706180310_《 Javascript (ES6)给变量一个hash串》的主要内容,如果未能解决你的问题,请参考以下文章
__x__(79)1016第十五天__ JavaScript 对象的继承