Get Programming with JavaScript - Listing 3.13
Listing 3.13 - A calendar event
var event = {
    title : "Appraisal Meeting",
    startDate : "2016-10-04 16:00:00",
    endDate : "2016-10-04 17:00:00",
    location : "Martha's office",
    importance: 1,
    notes : 'Don\'t forget the portfolio!'
};
        Further Adventures
Listing 3.13 - A calendar event - Task 4
- Add a backslash to the location property.
 - Log the location property.
 
var event = {
    title : "Appraisal Meeting",
    startDate : "2016-10-04 16:00:00",
    endDate : "2016-10-04 17:00:00",
    location : "Martha\'s office",    // add a backslash
    importance: 1,
    notes : 'Don\'t forget the portfolio!'
};
console.log(event.location);          // log the location
        The backslash has no effect. The single quotation mark works without the backslash and with the backslash.
Listing 3.13 - A calendar event - Task 5
- Include a backslash in a string so it will be displayed.
 
var event = {
    title : "Appraisal Meeting",
    startDate : "2016-10-04 16:00:00",
    endDate : "2016-10-04 17:00:00",
    location : "Martha's off\\ice",    // include a backslash
    importance: 1,
    notes : 'Don\'t forget the portfolio!'
};
console.log(event.location);    // display the string with the backslash
        A single backslash is used for escape sequences, to specify characters that you cannot type directly.
To include an actual backslash in a string, use a double backslash: \\.
The double backslash is an escape sequence that specifies a backslash.