JavaScript ignores spaces, tabs, and newlines that appear between "tokens" in programs, except those that are part of string constants. A "token" is a keyword, variable name, number, function name, or some other place where you would obviously not want to insert a space or a line break. If you place a space or tab or newline within a token, you obviously break it up into two tokens--123 is a single numeric token and 12 3 contains two separate tokens (and constitutes a syntax error, incidentally).
Because you can use spaces, tabs, and newlines freely in your program (except in strings and tokens) you are free to format and indent your programs in a neat and consistent way that makes the code easy to read and understand.
file: /Techref/language/java/script/definitive/ch02_02.htm, 3KB, , updated: 2019/10/14 15:00, local time: 2024/11/15 01:40,
18.119.160.13:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://linistepper.com/techref/language/java/script/definitive/ch02_02.htm"> [Chapter 2] 2.2 Whitespace and Line Breaks</A> |
Did you find what you needed? |