How much should be a JavaScript Line Length?

JavascriptWeb DevelopmentFront End Technology

Try to keep the length of lines less than 80 characters. This would make the code easier to read. Best practice is to move to next line using break if JavaScript statements aren’t fitting in a single line.

In addition, move to next line only after a comma or operator. For example, you can add statement like this, with a break after operator,

function display() {
   var a = "";
   a = a + isNaN(6234) + ": 6234<br>";
   a = a + isNaN(-52.1) + ": -52.1<br>";

   a = a + isNaN('') + ": ''<br>";
   document.getElementById("test").innerHTML = a;
Updated on 17-Jan-2020 09:59:56