Skip to content

Instantly share code, notes, and snippets.

@dherman
Created April 23, 2012 17:05
Show Gist options
  • Save dherman/2472325 to your computer and use it in GitHub Desktop.
Save dherman/2472325 to your computer and use it in GitHub Desktop.
ES6 template string syntax
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: ${"`"}`);
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: ${"'''"}''');
@modeswitch
Copy link

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.

@valueof
Copy link

valueof commented Apr 23, 2012

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