Created
December 29, 2017 18:20
-
-
Save tbsvttr/86cf033443055f0aa44f7102f346adba to your computer and use it in GitHub Desktop.
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
// Usage of quotes as wrappers of string literals an within those string literals | |
var name = 'Tobias'; // String literal wrapped in single quotes. | |
var planet = "Earth"; // String literal wrapped in double quotes. | |
// Usage of single quotes within a string literal wrapped in double quotes. | |
var firstQuote = "They said the product is 'good'."; | |
// Usage of double quotes within a string literal wrapped in single quotes. | |
var secondQuote = 'They said the product is "good".'; | |
// Those would not work (without escaping) | |
var firstQuote = 'They said the product is 'good'.'; | |
var secondQuote = "They said the product is "good"."; | |
// Usage of the escape character | |
var doubleQuote = "\""; // Gives a string literal with one double quote in it. | |
var singleQuote = '\''; | |
var backslash = '\\'; | |
var slash = '\/'; | |
var backspace = '\b'; | |
var formfeed = '\f'; | |
var newline = '\n'; | |
var carriageReturn = '\r'; | |
var tab = '\t'; | |
var verticalTab = '\v'; | |
var unicodeCodepoint = '\uXXXX'; | |
var nullCharacter = '\0'; | |
// Template literals, added in ECMAScript 2015, using backticks instead of quotes. | |
var text = `hello world` | |
var text = `hello! | |
world!` | |
var who = 'Tobias' | |
var text =`hello ${who}` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment