I've read several posts on this topic here, but I'm still uncertain how I should handle this issue.
In truth, the lines are in the source code much longer e.g.
console.log("html : "+"<li><a href=\""+el.find("link").text()+"\">"+el.find("title").text()+"</a>");
breaking it up in
console.log("html : "
+"<li><a href=\""
+el.find("link").text()
+"\">"
+el.find("title").text()
+"</a>");
everything still works fine, but JSLint tells me "Bad line breaking before '+'"
What is the best practice, recommend way to keep the source human readable (production code will be minified).
You must end line with +
Otherwise interpreters might treat it as the end of a line. ( thanks to Scimonster for explanation )
console.log('html: ' +
'<li><a href="' +
el.find('link').text() +
'">' +
el.find('title').text() +
'</a>');
I recommend you to use single quotes in your JavaScript and double quotes in HTML. Then there is no need to escape double quotes, it also improves readability of your code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With