ES6 Symbols

node v0.12.18
version: 2.0.0
endpointsharetweet
Symbols are a new data type in JavaScript that you can use to add properties to objects without colliding with other strings:
var myToStringSymbol = Symbol("toString")
var object = { }; // We'll use this symbol to describe the method without overwriting it. object[myToStringSymbol] = "this method will print a string"; // Print both, to show they're both still there. console.log(object[myToStringSymbol], object["toString"]);
You can use many of the built in symbols to take advantage of the new features added to objects in ES6. For example, we can use the global iterator Symbol to define how a custom object should behave in for...of:
var cart = { items: ["pizza", "car", "pastrami"], [Symbol.iterator] : function* () { for (var i = 0; i < this.items.length; ++i) yield this.items[i]; } } for (item of cart) console.log(item + " is in your cart!");
To learn more about Symbols, go to https://hacks.mozilla.org/2015/06/es6-in-depth-symbols/.
Loading…

26 comments

  • posted 3 years ago by hexorarix
    🌟🌠
  • posted 12 hours ago by xsjybldb
    1
  • posted 12 hours ago by xsjybldb
    1
  • posted 12 hours ago by xsjybldb
    -1 OR 2+918-918-1=0+0+0+1 --
  • posted 12 hours ago by xsjybldb
    -1 OR 2+518-518-1=0+0+0+1
  • posted 12 hours ago by xsjybldb
    -1' OR 2+976-976-1=0+0+0+1 --
  • posted 12 hours ago by xsjybldb
    -1' OR 2+92-92-1=0+0+0+1 or 'B55VbVdw'='
  • posted 12 hours ago by xsjybldb
    -1" OR 2+183-183-1=0+0+0+1 --
  • posted 12 hours ago by xsjybldb
    if(now()=sysdate(),sleep(15),0)
  • posted 12 hours ago by xsjybldb
    0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
  • posted 12 hours ago by xsjybldb
    0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z
  • posted 12 hours ago by xsjybldb
    (select(0)from(select(sleep(15)))v)/*'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"*/
  • posted 12 hours ago by xsjybldb
    -1; waitfor delay '0:0:15' --
  • posted 12 hours ago by xsjybldb
    -1); waitfor delay '0:0:15' --
  • posted 12 hours ago by xsjybldb
    1 waitfor delay '0:0:15' --
  • posted 12 hours ago by xsjybldb
    o1YX4I5F'; waitfor delay '0:0:15' --
  • posted 12 hours ago by xsjybldb
    -5 OR 54=(SELECT 54 FROM PG_SLEEP(15))--
  • posted 12 hours ago by xsjybldb
    -5) OR 688=(SELECT 688 FROM PG_SLEEP(15))--
  • posted 12 hours ago by xsjybldb
    -1)) OR 13=(SELECT 13 FROM PG_SLEEP(15))--
  • posted 12 hours ago by xsjybldb
    2pcRPdvb' OR 493=(SELECT 493 FROM PG_SLEEP(15))--
  • posted 12 hours ago by xsjybldb
    RNBwCbuY') OR 987=(SELECT 987 FROM PG_SLEEP(15))--
  • posted 12 hours ago by xsjybldb
    vRUldZxr')) OR 740=(SELECT 740 FROM PG_SLEEP(15))--
  • posted 12 hours ago by xsjybldb
    1*DBMS_PIPE.RECEIVE_MESSAGE(CHR(99)||CHR(99)||CHR(99),15)
  • posted 12 hours ago by xsjybldb
    1'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'
  • posted 12 hours ago by xsjybldb
    1'"
  • posted 12 hours ago by xsjybldb
    @@gQaU0

sign in to comment