JavaScript Flashcards
(247 cards)
What is the purpose of variables?
Purpose of variables is to store data/information.
How do you declare a variable?
Declaring a variable you need the variable keyword: var and giving it a name: variable name.
How do you initialize (assign a value to) a variable?
You assign a value by using the assignment operator: ‘=‘
What characters are allowed in variable names?
Characters allowed in the variable names are letters, dollar sign, and underscore
What does it mean to say that variable names are “case sensitive”?
When variables are “case sensitive” the same named variable is different when one of the words are capitalized.
What is the purpose of a string?
Purpose of a string is to add new content into a page.
What is the purpose of a number?
Purpose of a number is calculating, determining the size of the screen, moving the position of an element, or setting the amount of time an element should take to fade in.
What is the purpose of a boolean?
Purpose of a boolean is to determine which part of a script should run.
What does the = operator mean in JavaScript?
“=“ means the value is being assigned to a variable
How do you update the value of a variable?
You use the same variable and assign it to the new value
What is the difference between null and undefined?
undefined is a variable that hasn’t been defined to anything and null is a variable that is intentionally missing a value.
Why is it a good habit to include “labels” when you log values to the browser console?
Labels can help us with what we’re referring to specific variables/values.
Give five examples of JavaScript primitives.
5 primitives: null, undefined, string, boolean, number
What data type is returned by an arithmetic operation?
Number
What is string concatenation?
When you’re joining multiple strings into 1 string
What purpose(s) does the + plus operator serve in JavaScript?
Adding values and concatenation strings
What data type is returned by comparing two values (<, >, ===, etc)?
Boolean
What does the += “plus-equals” operator do?
It adds the value to a variable and then assigns the result to the variable
What are objects used for?
Objects are used to store/group data
What are object properties?
Object properties are variables associated with the object
Describe object literal notation.
Object Literal Notation consists of the variable object with properties and methods, and in the properties consists of keys and values, methods consists of functions.
How do you remove a property from an object?
delete
What are the two ways to get or update the value of a property?
dot or bracket notations
What is a function in JavaScript?
Its a set a statements that perform a task