Created
April 23, 2012 17:05
-
-
Save dherman/2472325 to your computer and use it in GitHub Desktop.
ES6 template string syntax
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log(` | |
Usage: node ${process.argv[1]} [OPTIONS] | |
-h print this usage information | |
-L launch the nuclear missiles | |
-k draw a kitty | |
`); | |
// including a backtick | |
console.log(`The backtick character: ${"`"}`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log(""" | |
Usage: node ${process.argv[1]} [OPTIONS] | |
-h print this usage information | |
-L lunch the nuclear missiles | |
-k draw a kitty | |
"""); | |
console.log(''' | |
Usage: node ${process.argv[1]} [OPTIONS] | |
-h print this usage information | |
-L lunch the nuclear missiles | |
-k draw a kitty | |
'''); | |
// including a triple-quote: | |
console.log("""The triple-quote sequence: ${'"""'}"""); | |
console.log('''The triple-quote sequence: ${"'''"}'''); |
Expanding my tweet-reply to @dherman: I use both Python (tripple-quotes) and Go (backticks) and I like backticks more: they are much more lightweight.
Also, you may find this email by Guido (he's against backticks) interesting: http://mail.python.org/pipermail/python-ideas/2007-January/000054.html
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Would prefer triple-quotes, if only because they're familiar from Python. Backticks are less intuitive because of their historical usage in certain shell scripting languages.