1. 程式人生 > >es6 Symbol

es6 Symbol

bsp pre ons console cnblogs span code blog str

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