literal in js code example

Example 1: string literal javascript

`string text`

`string text line 1
 string text line 2`

`string text ${expression} string text`

tag`string text ${expression} string text`

Example 2: object literal javascript

// Object literals are defined using the following syntax rules:
// A colon separates property name from value.
// A comma separates each name-value pair from the next.
// There should be no comma after the last name-value pair.

// If any of the syntax rules are broken, such as a missing comma or colon or curly brace,
// an error will be thrown.

var myObject = {
    sProp: 'some string value',
    numProp: 2,
    bProp: false
};

Example 3: javascript string literal

// Template String: If you want both double and single quotations in your string
// NOTE: also allows multiple line strings
// Find it above the leftmost tab key on your keyboard
let AllQuotationString = `Can use this for ', or ", or ${yourVariable}, or
	multiline strings`;

// Single Quotation String: If you want double quotations in your string
let SingleQuotationString = 'can contain " in string, but not ${yourVariable}';

// Double Quotation String: If you want single quotations in your string
let DblQuotationString = "can contain ' in string, but not ${yourVariable}";

Example 4: javascript strin literal

const stringLiteral = `text string ${expression} text string`;

Example 5: string literals javascript

`string text`

`string text line 1
 string text line 2`

`string text ${expression} string text`

tag`string text ${expression} string text`