In JavaScript, a piece of information is a value. There are different kinds of values; the kind you’re most familiar with are numbers. A string value is characters—such as a word or words—enclosed in quotes. Other kinds of JavaScript values are listed in Table 1.2.
Type | Description | Example |
---|---|---|
Number | Any numeric value | 3.141592654 |
String | Characters inside quote marks | “Hello, world!” |
Boolean | True or False | true |
Null | Empty and meaningless | |
Object | Any value associated with the object | |
Function | Value returned by a function |
Variables contain values. For example, the variable myName is assigned the string “Dori”. Another way to write this is myName = "Dori". The equals sign can be read as “is set to.” In other words, the variable myName now contains the value “Dori”.
✓ Tips
JavaScript is case sensitive. This means that myname is not the same as myName, and neither is the same as MyName.
Variable names cannot contain spaces or other punctuation, or start with a digit. They also can’t be one of the JavaScript reserved words. See Appendix B for a list of JavaScript reserved words.
18.222.164.228