We don't need to add semicolon at end of the statement in javascript, it will add automatically. It will consider every line as statement. So you have to use string concatenation for declaring multiline strings. ES6 has given a feature to avoid string concatenation for multiline strings
Using ES5
Here we are using string cancatenation
var tmp = 'line 1 ' + 'line 2 ' + 'line 3 ' + 'line 4 '; console.log(tmp);
Using ES6
Here we are back quotes from ES6
var tmp = `line 1 line 2 line 3 line 4 `; console.log(tmp); alert(tmp);
0 comments:
Post a Comment