JavaScript Flashcards
What is the purpose of variables?
Store information for the script to its job.
How do you declare a variable?
First use the variable keyword, then the variable name.
How do you initialize (assign a value to) a variable?
After the variable name use the equal sign or assignment operator then the variable value.
What characters are allowed in variable names?
letters, underscore, dollar sign, numbers.
What does it mean to say that variable names are “case sensitive”?
The language keywords, variables, function names, and any other identifiers must always be typed with a consistent capitalization of letters.
What is the purpose of a string?
Working with any kind of text. Represent and manipulate a sequence of characters.
What is the purpose of a number?
Working with numeric data.
What is the purpose of a boolean?
Create true or false statements. Determine which part of a script should run.
What does the = operator mean in JavaScript?
Is an assignment operator. Is used to give the value to a variable.
How do you update the value of a variable?
Just use the variable name, the equals sign and the new value.
What is the difference between null and undefined?
Undefinided is a variable has been declared but has not been assigned a value. Null is an assignment value. It can be assigned to a variable as a representation of no value.
Why is it a good habit to include “labels” when you log values to the browser console?
Is good to avoid confusions between similar values.
Give five examples of JavaScript primitives.
String, number, boolean, null, undefined.
What data type is returned by an arithmetic operation?
Numerical value.
What purpose(s) does the + plus operator serve in JavaScript?
The addition operator ( + ) produces the sum of numeric operands or string concatenation
What data type is returned by comparing two values (<, >, ===, etc)?
A boolean value (true or false).
What does the += “plus-equals” operator do?
The addition assignment operator (+=) adds the value of the right operand to a variable and assigns the result to the variable.
What is string concatenation?
Join two or more strings values into one value.
What are object properties?
An association between a name (or key) and a value
Describe object literal notation.
Value pairs, with a colon separating the keys and values, and a comma after every key:value pair, except for the last one
How do you remove a property from an object?
Using the delete operator.
What are the two ways to get or update the value of a property?
With a dot and with brackets.
What are objects used for?
For store data as properties (key-value pairs).
What are arrays used for?
Used to store values that are related to each other.