JavaScript Flashcards
(109 cards)
What is the purpose of variables?
tto tem,porarily store information for the computer to use in order to get the desired result
How do you declare a variable?
using a keyword like var, const or let
How do you initialize (assign a value to) a variable?
you assign it a value with the equal operator
What characters are allowed in variable names?
$, letters and _underscore not numbers
What does it mean to say that variable names are “case sensitive”?
it means, the the same word written with different cases are two different variables
What is the purpose of a string?
holds words, inside quotation marks, can add written information for user, works with any kind of text
What is the purpose of a number?
to allow the computer to calculate as well as moving elements on a page, holds numeric value;
What is the purpose of a boolean?
to give the computer true or false data, it helps ‘check’ things, allows for true or false
What does the = operator mean in JavaScript?
ther assignment operator assigns a value to variable names
How do you update the value of a variable?
you do not have to declare it again, you just use the assignment operator
What is the difference between null and undefined?
undefined is the immediate value of a variable if it hasn’t been assigned a value or for formal arguments where there are nno actual arguments
In computer science, a null value represents a reference that points, generally intentionally, to a nonexistent or invalid object or address. The meaning of a null reference varies among language implementations.
null can also be used for a place to store a value to be changed later
Why is it a good habit to include “labels” when you log values to the browser console?
so that you keep track of your consoles
tells you what line number you’re on
Give five examples of JavaScript primitives.
null, undefined, string data, numeric data, boolean data
Difference between primitive and reference data types
primitives stores the variable in memory location
reference stores the address of where the information is
What data type is returned by an arithmetic operation?
Arithmetic operators take numerical values (either literals or variables) as their operands and return a single numerical value.
A number
What is string concatenation?
Concatenate just means “join together”. To join together strings in JavaScript you can use a different type of string, called a template literal.
‘string’ + ‘string’
${string}
What purpose(s) does the + plus operator serve in JavaScript?
addition of number values, and string concatenation
+ operator if it receives two numbers it knows it needs to add,
if it receives a string, it knows to concantenate
What data type is returned by comparing two values (<, >, ===, etc)?
true or false, boolean
What does the += “plus-equals” operator do?
adds a value to the right and updates the variable
What are objects used for?
objects group together a set of variables and functions that create a model of something that exists in the real world
grouping variables together
What are object properties?
in an object, variables are known as properties - they can hold information like the name of a hotel
name: ‘Hilton’ -> that is the property
Describe object literal notation.
var object = { name(key): louisa(value) }
key value pairs
var keyword var object ope
How do you remove a property from an object?
delete operator
delete pet.name
What are the two ways to get or update the value of a property?
person.name
person[name]
dot or bracket notation