To create a variable, start with the keyword var followed by an acceptable symbolic name for the variable ( data in the following examples ).
To assign a value, the variable name must be to the left of an equals sign, with the new value on the right side.
var data data = 123 // or var data = 123
Sometimes you’ll see the keywords let or const instead of var. They have slightly different uses, but var will work 99.99999% of the time.
If a var isn’t given any value, it’s considered undefined or null. Null is a keyword used to indicate an empty value. You can use null to erase a variable too.
var data // or var data = null // or var data = 123 data = null
Numbers are any valid number values- whole numbers, decimals, etc. There is no distinction between ints and floats, etc.
var data = 1 // or var data = 1.174 // or var data = 0x8A4F
Strings are groups of one or more characters, surrounded by single or double quotes, or backticks. Strings can be made up of numbers, letters, symbols, etc.
var data = 'string' // or var data = "string" // or var data = `string`
A boolean is a simple true or false value. This can be set to a variable literally using the true and false keywords, but other values work too. Non-zero numbers, for instance, evaluate to true, while 0 and null evaluate to false.
var data = false // or var data = 0 // or var data = null
Data can also be stored in more complex data storage structures, like arrays and objects. Arrays are a group of variables addressable by a single name. Objects can have properties, methods, etc, similar to other languages. Those will be covered in part two.