Bob Downs

. Why should you end every JavaScript statement with a semicolon?
Bob Downs
Even though the statements do not end in semicolons, the preceding script is legal. However, that’s not the end of the story. Programmers often adopt conventions in their code that make the code easier for themselves or other programmers to read in a text editor. In the case of semicolons, it is considered good JavaScript programming practice to end every statement with a semicolon. The semicolon serves to identify the end of each statement, making it easier for a programmer to read his or her own code (and for other programmers to read the code later on). In addition, a JavaScript parser must perform work on a script without semicolons to determine where each statement ends, which can slow down a web page and detract from the user experience. For these reasons, you should be sure to end all of your JavaScript statements with semicolons.
JavaScript: The Web Warrior Series
Rate this book
Clear rating