JavaScript syntax is a set of rules that define how JavaScript programs are written and interpreted by the browser.
JavaScript code is generally written inside the HTML script tag.
You can also save JavaScript code in an external file with the .js extension.
JavaScript uses the Unicode character set.
JavaScript is a case-sensitive programming language.
| Word 1 | Word 2 | Same? |
|---|---|---|
| name | Name | No |
| myFunction | MyFunction | No |
| age | Age | No |
Always use the correct capitalization while writing JavaScript code.
Variables are used to store data in JavaScript.
A variable can store text, numbers, and other types of data.
A JavaScript program consists of one or more statements. Statements tell the browser what action to perform.
Each line above is a JavaScript statement.
Semicolons separate JavaScript statements. They are optional but recommended.
Both styles work, but using semicolons improves readability.
JavaScript ignores extra spaces and tabs.
Use spaces to make your code easier to read.
Comments explain the code and are ignored during execution.
A string is text enclosed in quotation marks.
Both methods are valid in JavaScript.
Numbers should not be enclosed in quotation marks.
Boolean values can only be true or false.
Keywords are reserved words that have special meanings in JavaScript. They cannot be used as variable names or function names.
| Keyword | Keyword | Keyword |
|---|---|---|
| var | function | if |
| else | do | while |
| for | switch | break |
| continue | return | try |
| catch | finally | debugger |
| case | class | this |
| default | true | false |
| in | instanceof | typeof |
| new | null | throw |
| void | with | delete |
Is JavaScript a case-sensitive language?