JavaScript Flashcards
JavaScript Primitives and Variables
What is the purpose of variables?
To store data so that we can go back to variables later
JavaScript Primitives and Variables
How do you declare variable?
Create the variable name and give it a name.
Ex) var name
JavaScript Primitives and Variables
How do you initialize (assign a value to) a variable?
The equal sign (=) is an assignment operator. It says that you are going to assign a value to the variable. It also used to update the value given to a variable
ex) var keyword variable name = value
JavaScript Primitives and Variables
What characters are allowed in variable names?
A letter, dollar sign($) or an underscore(_). It must not start with a number
JavaScript Primitives and Variables
What does it mean to say that variable names are “case sensitive”?
-If two variables are the same words but one has upper-case and other one has lower-case, it becomes different variables.
JavaScript Primitives and Variables
What is the purpose of a string?
Strings can be used when working with any kind of text.
storage for characters
JavaScript Primitives and Variables
What is the purpose of a number?
To count or calculate sums and store numeric values
JavaScript Primitives and Variables
What is the purpose of a boolean?
To make decisions. For example, yes or no
JavaScript Primitives and Variables
What does the = operator mean in JavaScript?
It is assignment operator. Assign value to the variable
JavaScript Primitives and Variables
How do you update the value of a variable?
Assign new variable value
JavaScript Primitives and Variables
What is the difference between null and undefined?
Undefined is empty for some reason but we don’t know why it is empty. Undefined is a computer (JavaScript) saying nothing. cannot tell which said undefined.
- Null is assigned by humans, not JavaScript.
- Null is an empty value that needs to be assigned at some point. It made the empty on purpose to put values later.
JavaScript Primitives and Variables
Why is it a good habit to include “labels” when you log values to the browser console?
Help others and myself where these values are coming from. Benefit others and yourself in the future
JavaScript Primitives and Variables
Give five examples of JavaScript primitives
Undefined, null, number, string, boolean
JavaScript Operators and Expressions
What data type is returned by an arithmetic operation?
Numeric/Number
JavaScript Operators and Expressions
What is string concatenation?
Join two or more strings to create one new string
JavaScript Operators and Expressions
What purpose(s) does the + plus operator serve in javaScript?
Add one value to another
The additional operator (+) produces the sum of numeric operands or string concatenation.
JavaScript Operators and Expressions
What data type is returned by comparing two values(, ===, etc)?
boolean
JavaScript Operators and Expressions
What does the += ‘plus-equals’ operator do?
Value on the right side added to the left variable, and then get new value.
JavaScript Objects
What are objects used for?
Group of data and functionality.
Data type to store further data with individual properties.
JavaScript Objects
What are object properties?
Individual key correlates with value
JavaScript Objects
Describe object literal notation
opening and closing curly braces
JavaScript Objects
How do you remove a property from an object?
Delete operator and name of object.property
JavaScript Objects
What are the two ways to get or update the value of a property?
To update the value of properties, use dot notation or square brackets.
JavaScript Arrays
What are arrays used for?
list of data