JavaScript Flashcards
What is the purpose of variables?
To store or remember information.
How do you declare a variable?
- var
- let
- const
How do you initialize (assign a value to) a variable?
Using one equal sign.
What characters are allowed in variable names?
- Variable names must start with a letter, underscore, or dollar sign.
- Variable names cannot contain spaces.
- Variable names can only contain letters, numbers, underscores, and dollar signs.
- Variable names are case-sensitive.
What does it mean to say that variable names are “case-sensitive”?
Variable names have to be specific. (firstname & firstName are two different variables).
What is the purpose of a string?
Used to represent and manipulate a series of characters.
What is the purpose if a number?
Used to represent and manipulate numbers.
What is the purpose of a boolean?
Used when determining which part of a script should run. (True or false).
What does the = operator mean in JavaScript?
Assigns a value to a variable.
How do you update the value of a variable?
By using the name of the variable and assigning it a new value.
What is the difference between null and undefined?
- Null is a type of object that is intentionally given no value.
- Undefined is when a variable is defined, but never given a value.
What data type is returned by an arithmetic operation?
Number.
What is a string concatenation?
Joining strings together to create one new string.
What purpose(s) does the + plus operator serve in JavaScript?
To add numbers and concatenate strings.
What data type is returned by comparing two values (, ===, etc)?
Boolean.
What does the += “plus-equals” operator do?
It adds the value of the right operand to a variable and assigns the result to the variable.
What are objects used for?
To group together a set of variables and functions to create a model of something you would recognize from the real world.
What are object properties?
- Variables with values.
* Allow us to store information in an object literal.
Describe literal notation.
- Assigning an object literal to a variable.
* Within the object, there are properties (variables) and methods (functions).
How do you remove a property from an object?
- By using the delete keyword followed by the object name and property name
- By using the delete operator.
What are two ways to get or update the value of a property.
- object.property-name = value - Dot Notation
* object[‘property-name’] = value - Bracket Notation
Why do we log things to the console?
To debug and see if the output is what you want it to be.
What is a method?
A function which is a property of an object.
How is a method different from any other function?
A method is associated/attached with an object.
How do you remove the last element from an array?
Using the Array.prototype.pop() method.
How do you round a number down to the nearest integer.
Using the Math.floor() method.