JavaScript Flashcards
What is the purpose of variables?
Variables are for storing bits of information.
How do you declare a variable?
Variables are declared using the variable keyword and variable name. For example, var quantity; is a variable declaration.
How do you initialize (assign a value to) a variable?
Variables are initialized by using the assignment operator ‘=’.
What characters are allowed in variable names?
Variable names will accept letters, numbers, dollar signs, and underscores. However, variable names cannot start with a number.
What does it mean to say that variable names are “case sensitive”?
This means that 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?
The purpose of a string is to store and manipulate text.
What is the purpose of a number?
Numbers are primarily used for arithmetic expressions.
What is the purpose of a boolean?
A boolean denotes a true or false value which allows a program to analyze and respond to conditions.
What does the = operator mean in JavaScript?
The = operator is used to assign values to variables.
How do you update the value of a variable?
You can update the value of a variable by using the assignment operator to store a new value.
What is the difference between null and undefined?
A null value is assigned intentionally, whereas a value of undefined is typically given by JavaScript.
Why is it a good habit to include “labels” when you log values to the browser console?
Labels improve readability and aids in debugging when you log values to the browser console.
Give five examples of JavaScript primitives.
String, number, boolean, null, and undefined are five examples of JavaScript primitives.
What data type is returned by an arithmetic operation?
An arithmetic operation returns a data type of number.
What is string concatenation?
Concatenation is the process of appending one string to the end of another string.
What purpose(s) does the + plus operator serve in JavaScript?
The + plus operator is used to perform addition in JavaScript. You can also concatenate strings by using the + plus operator.
What data type is returned by comparing two values (, ===, etc)?
Comparing two values will return a data type of boolean.
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 are objects used for?
Objects group together a set of variables and functions to create a model of a something you would recognize from the real world.
What are object properties?
A property is a variable within an object.
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.
How do you remove a property from an object?
You can remove a property from an object using the delete keyword.
What are the two ways to get or update the value of a property?
You can use dot and bracket notation to get or update the value of a property.
What are arrays used for?
An array is used to store a list of values.
Describe array literal notation.
Array literal notation is where you define a new array using just empty brackets.
How are arrays different from “plain” objects?
?
What number represents the first index of an array?
The first index of an array is represented by the number 0.
What is the length property of an array?
The length property of an array returns the number of elements in that array.
How do you calculate the last index of an array?
You can calculate the last index of an array by subtracting 1 from the array’s length.
What is a function in JavaScript?
A JavaScript function is a block of code designed to perform a particular task.
Describe the parts of a function definition.
A function definition includes the name of the function. A list of parameters to the function, enclosed in parentheses and separated by commas. It also includes the JavaScript statements that define the function, enclosed in curly brackets,
Describe the parts of a function call.
A function call is comprised of the function’s name followed by parentheses. Arguments go inside of the parentheses separated by commas.
When comparing them side-by-side, what are the differences between a function call and a function definition?
A function call is the name of the function followed by parentheses which may contain arguments separated by commas. Whereas a function definition is made up of the function keyword, an optional name, and parentheses which may include parameters separated by commas. Function definitions also include JavaScript statements that define the function which are enclosed in curly brackets.
What is the difference between a parameter and an argument?
Parameters are used in a function’s definition whereas arguments are used when a function is being called or ‘invoked’.