1.2 Flashcards
What are the six primitive data types?
Strings Numbers Booleans Null Undefined Symbol
String
Text that is generally wrapped in single or double quotes
\
What is the backslash used for in a string?
If you wanted to include a double/single quote within a string.
It’s used to escape and tell Javascript that the quotes should be displayed as quotes
var escapeText = “He said: \”Yes!”\, that’s for sure.”;
What does concatenation mean?
To combine strings
Use the + sign to join strings
Integer
A number with no decimal points.
Everyday round numbers: 1, 5, 17, 5,394 etc
A float
Anything that does have a decimal point with at least one number following the point
Boolean
True or False
Null
Indicated that the value has been set to be empty purposefully
Undefined
Indicates that the value was never set
Objects
Contains a set of key-value pairs.
Like an unordered list of data
var car = {
color: ‘red’,
mileage: 10
};
Array
Ordered lists of data items.
Items inside done have keys.
Simply a list of data values
Arrays are indicated by comma-separated values between square brackets. Just like with normal objects, you can either place all the values on the same line or give each of the values their own line:
var numberArray = [1, 2, 3]; // or var numberArray2 = [ 1, 2, 3 ];
// array of strings
var foodArray = [‘pizza’, ‘tuna’, ‘apple’];
// array of objects
var carArray = [ { type: 'Bus', wheels: 4, color: 'blue'}, { type: 'Sport', wheels: 4, color: 'red'} ];
// array of arrays
var myCalculatorNumbers = [ [1, 2, 3], [3, 4, 6], [7, 8, 9] ];