📚 node [[javascript data types]]
Variables and data types
Note These notes follow on from [[Javascript - Absolute Basics]]
Variables
A container for a value so that it can be reused
Declaring a variable
Here's the basic syntax:
var firstname = "John";
He uses single quotes and says single quotes are more 'modern' :P
5 basic data types in JavaScript
- Number: Floating point numbers, for decimals and integers
- String: Sequence of characters, used for text
- Boolean: Logical data type that can only be TRUE or FALSE
- Undefined: Data type of a variable that does not have a value yet
- Null: Also means 'non-existent'
In JavaScript, all numbers are Floating Point, there are no distinct number types.
Best Practice - Always give variables a meaningful name
Best Practice - JavaScript uses CamelCase for its variables
Rules
-
You cannot name a variable
- With a keyword
-
By starting it with anything but
- character
- underscore
- dollar sign
📖 stoas
- public document at doc.anagora.org/javascript-data-types
- video call at meet.jit.si/javascript-data-types
⥱ context
↑ pushing here
(none)
(none)
↓ pulling this
(none)
(none)
🔎 full text search for 'javascript data types'