JavaScript Flashcards
What is the purpose of variables?
To remember data for future reference.
How do you declare a variable?
Write down keyword (var) to declare that variable.
How do you initialize (assign a value to) a variable?
By using a single = sign, (= meaning assignment).
What characters are allowed in variable names?
Letters, $, _ anywhere and numbers ,but number needs to be at the end.
What does it mean to say that variable names are “case sensitive”?
JavaScript does not consider lowercase and uppercase the same.
What is the purpose of a string?
A way to hold a sequence of characters represented with letter characters.
What is the purpose of a number?
To store numbers for calculation.
What is the purpose of a boolean?
It allows us to render what is or isn’t.
What does the = operator mean in JavaScript?
To assign a thing.
How do you update the value of a variable?
No keyword is necessary.
What is the difference between null and undefined?
Null can only be assigned and not generated by JavaScript, undefined comes from JavaScript.
Why is it a good habit to include “labels” when you log values to the browser console?
To know what you are looking at specifically.
Give five examples of JavaScript primitives.
String, number, boolean, null, and undefined.
What data type is returned by an arithmetic operation?
A number.
What is string concatenation?
Any type of values being added to a string which results in one string.
What purpose(s) does the + “plus” operator serve in JavaScript?
It can concatenate or be used for addition.
What data type is returned by comparing two values (<, >, ===, etc)?
Boolean
What does the += “plus-equals” operator do?
It adds the value to the variable and assigns that result to the variable.
What are objects used for?
To group together a set of properties, variables and functions to give it grouping in one location.
What are object properties?
The piece of data represented by the key and value.
Describe object literal notation?
The data inside the {} for example: properties or key and values.
How do you remove a property from an object?
With the delete operator and . name of the property
What are the two ways to get or update the value of a property?
You can use dot notation or bracket notation.
What are arrays used for?
Good for rendering a list of data of any length and where the order is important or unimportant.
Describe array literal notation.
Opening bracket and closing bracket with any number of data types inside the array.
How are arrays different from “plain” objects?
All arrays have a length property while objects do not.
What number represents the first index of an array?
Number 0.
What is the length property of an array?
True count of how many items are in that array.
How do you calculate the last index of an array?
Subtract 1 from the length property of an array.
What is a function in JavaScript?
To group a series of statements together to preform a specific task.
Describe the parts of a function definition.
Function, name for the function, parameters in a set of (), and a code block {}.
Describe the parts of a function call.
Function name ().
When comparing them side-by-side, what are the differences between a function call and a function definition?
There is no code block in a call and the function keyword.
What is the difference between a parameter and an argument?
Arguments are values provided when a function is called and parameter are values provided when a function is defined.