Symbols

https://hacks.mozilla.org/2015/06/es6-in-depth-symbols/

 <script>
function w(wcon) {
console.log(wcon)
}
w(Symbol)
w(Symbol())
w(Symbol("foo") !== Symbol("foo"))
//true
const foo = Symbol()
w(foo)
const bar = Symbol()
typeof foo === "symbol"
w(typeof foo === "symbol")
//true
var sym = Symbol("<3");
// "your symbol is " + sym
// Uncaught TypeError: Cannot convert a Symbol value to a string
w(String(sym))
//Symbol(<3)
w(sym.toString())
//Symbol(<3)
w("your symbol is " + String(sym))
//your symbol is Symbol(<3)
w("your symbol is " + sym.toString())
//your symbol is Symbol(<3)
</script>
上一篇:jsContext全局函数调用与对象函数调用、evaluateScript


下一篇:大数据Hadoop入门视频教程:Hadoop的快如入门