0

It comes from an if statement they use es6 but never seen '/#' being used. Anyone care to explain. (note the backtick is remove from stackflow )

Here is the snippet of code: https://codedump.io/share/LPW9jWNDJZwl/1/weird-javascript Here is package.json if it can help: https://codedump.io/share/HlvwlcmeiPW9/1/packagejson

    // Flash around where you have just spawned
    if (`/#${this.socket.id}` === player.id &&
            player.moveCounter <= ClientConfig.TURNS_TO_FLASH_AFTER_SPAWN &&
            player.moveCounter % 2 === 0) {
        this.canvasView.drawSquareAround(player.segments[0], ClientConfig.SPAWN_FLASH_COLOR);
    }

    if (player.base64Image) {
        this.canvasView.drawImages(player.segments, player.base64Image);
    } else {
        this.canvasView.drawSquares(player.segments, player.color);
    }
}
Mr Smith
  • 3,318
  • 9
  • 47
  • 85
John
  • 29
  • 3
  • 3
    The `/#` in the template string is nothing special, it means literally those characters. It might become more clear if you read up on ES6 template strings. – Alexander O'Mara Jul 02 '16 at 05:14

1 Answers1

-1

Backticks are template literals. In this case,

`/#${this.socket.id}` becomes the string "/#1" assuming the value for this.socket.id is 1.

melpomene
  • 84,125
  • 8
  • 85
  • 148
pol
  • 161
  • 6