JavaScript Flashcards
(140 cards)
What is the purpose of variables?
Variables are used to store data that can be referenced and/or changed later on.
How do you declare a variable?
You can declare a variable using var (global scoped) or let, const (block scoped).
How do you initialize (assign a value to) a variable?
You assign a value to a variable using =
What characters are allowed in variable names?
Variables must start with a letter, underscore, or $ sign. You may not use any JavaScript keywords.
What does it mean to say that variable names are “case sensitive”?
This means that the variable names must always be typed with consisted capitalization of characters. Otherwise, they will be treated as different variables entirely.
What is the purpose of a string?
A string is used to store and manipulate text.
What is the purpose of a number?
JavaScript numbers are used to store numerical values as double precision floating point numbers
What is the purpose of a boolean?
Boolean variables are used to store a value of true or false, and are often used to evaluate the truth of an expression.
What does the = operator mean in JavaScript?
It is the assignment operator that is used to store the operand on the right side to the operand on the left side.
How do you update the value of a variable?
There are various ways to update the value of a variable. Besides the assignment operator, we can use +=, -=, *=. /=
What is the difference between null and undefined?
Null is an assigned value that means nothing. Undefined means that the variable has been declared but not defined yet.
Why is it a good habit to include “labels” when you log values to the browser console?
It is a good practice to include labels as it allows the developer to know exactly context of the data being displayed.
Give five examples of JavaScript primitives.
Undefined, null, boolean, number, string
What data type is returned by an arithmetic operation?
If both operands are numerical data, the operation will result in numerical data. However, if an operand is a string, then operation will result in a string.
What is string concatenation?
The arithmetic operation of two string operands.
What purpose(s) does the + plus operator serve in JavaScript?
The + operator is used to add operands on the left and right side of the operator.
What data type is returned by comparing two values (<, >, ===, etc)?
Boolean
What does the += “plus-equals” operator do?
The += operator adds the value of the right operand with the left operand and stores the result in the left operand.
What does the += “plus-equals” operator do?
The += operator adds the value of the right operand with the left operand and stores the result in the left operand.
What are objects used for?
An object is a self-contained component with its own properties, functions, and data structures. They are used to encapsulate their own actions from the rest of the program.
What are object properties?
Properties are values associated with a JavaScript object. Properties are in the form of key:value
Describe object literal notation.
The Object literal notation is basically an array of key:value pairs, with a colon separating the keys and values, and a comma after every key:value pair, except for the last, just like a regular array.
How do you remove a property from an object?
By using the delete operator.
What are the two ways to get or update the value of a property?
By using the dot nation or bracket notation
myCar.make
myCar[‘make’]