JavaScript Flashcards
what is the purpose of variables
Variables are containers for storing data
Variables store data values
How do you declare a varaible?
Ways to Declare a JavaScript Variable:
Using var
Using let
Using const
How do you initialize (assign a value to) a variable?
To initialize (assign a value to) a variable, you use the equal sign =
what characters are allowed in variable names?
variable names can’t contain spaces
variable names must begin with a letter, an underscore, or a dollar sign
variable names can contain letters, underscores, numbers, or dollar signs
variables are case sensitive
What does it mean to say that variable names are case sensitive?
It means that the case matters
cat =/= Cat
What is the purpose of a string?
JavaScript strings are for storing and manipulating text
what is the purpose of a number?
The purpose of numbers is to represent and manipulate numbers
what is the purpose of boolean?
A JavaScript Boolean represents one of two values: true or false.
Very often, in programming, you will need a data type that can only have one of two values, like
YES / NO
ON / OFF
TRUE / FALSE
For this, JavaScript has a Boolean data type. It can only take the values true or false.
what does the = operator mean in JavaScript?
the = operator is an assignment operator.
it assigns value to JavaScript variables
how do you update the value of a variable?
You update the value of a variable by reassigning it using the assignment operator =
what is the difference between null and undefined
The undefined property indicates that a variable has not been assigned a value, or not declared at all.
null is a special value that represents an empty or unknown value.
why is it a good idea to include labels when you log values to the browser console?
so you know when shit dont work
give five examples of JavaScript primitives
string, number, boolean, null, undefined
what data type is returned by an arithmetic operation
number data type is returned by arithmetic operation
what is string concatenation?
string concatenation is the combining of strings
what purpose does the addition (+) operator serve in JavaScript
the addition (+) can be used for arithmetic or concatenating strings
what data type is returned by comparing two values with logical operators?
boolean data type is returned when comparing two operands with logical operators
what does the addition assignment (+=) operator do?
the addition assignment (+=) operator assigns the result of the expression back to the first value
what are objects used for
An object is a collection of related data and/or functionality.
These usually consist of variables and functions
(which are called properties and methods when they are inside objects).
what are object properties?
An object is a collection of related data and/or functionality. These usually consist of several variables and functions (which are called properties and methods when they are inside objects).
describe object literal notation
{
key: value
}
How do you remove a property from an object?
To delete a property from an object, you can use the delete operator Delete Object.Property Delete person(object).name(property)
What are two ways to get or update the value of a property?
The two ways to get or update the value of a property are dot and bracket notation
What are arrays used for?
An array is a special variable, which can hold more than one value
Arrays are used to store data
Think of arrays as lists
Describe array literal notation
Array literal notation looks like the following: var newArr = []
How are arrays different from plain objects?
Objects represent things with properties and methods
Array create and store lists of data in a single variable
What number represents the first index of an array?
Zero is the number which represents the first index of an array
Arrays are based on zero index, meaning arrays start a 0 instead of 1
What is the length property of an array?
he length property of an array returns the length of an array
The length is 1 indexed, meaning the count starts at 1
The length is not 0 indexed
How do you calculate he last index of an array?
To calculate the last index of an array, you would use the .length property and subtract 1
You subtract 1 because .length property is 1 indexed, and arrays are 0 indexed
What is a function in JavaScript?
A JavaScript function is a block of code designed to perform a particular task
A JavaScript function is executed when something invokes/calls it
Describe the parts of a function definition (when a function is being created)
A JavaScript function is defined with the function keyword, followed by a name followed by parentheses
What characters are allowed for function names?
Function names can contain letters, digits, underscores, and dollar signs (same rule as variables)