JavaScript disregards multiple spaces. You can incorporate whitespace into your script to enhance readability.
The subsequent lines hold the same meaning:
let person = “Hege”; let person=“Hege”; |
It’s considered good practice to include spaces around operators ( = + – * / ).
let x = y + z; |
To improve readability, programmers often limit code lines to 80 characters. If a JavaScript statement exceeds this length, it’s best to break it after an operator.
Example
document.getElementById(“demo”).innerHTML = |
JavaScript statements can be grouped within code blocks, which are delimited by curly brackets {...}
. This organization allows for collective execution, often seen in JavaScript functions.
Example
function myFunction() { |