首页 > 代码库 > es6 Symbol

es6 Symbol

let s = Symbol()
console.log(typeof s)

let foo = Symbol(‘foo‘)
let bar = Symbol(‘bar‘)
console.log(foo);
console.log(bar);

console.log(foo === bar)  //false
let foo2 = Symbol(‘foo‘);
console.log(foo.toString() == foo2.toString())

 

es6 Symbol