Javascript Flashcards
What are objects used for?
In JavaScript, an object is a standalone entity, with properties and type. An object is a collection of related data and/or functionality. Objects can be used for data models
What are object properties?
A property of an object can be explained as a variable that is attached to the object. The properties of an object define the characteristics of the object.
Describe object literal notation.
opening and closing curly brace
How do you remove a property from an object?
delete operator followed by object.property
What are the two ways to get or update the value of a property?
bracket or dot notation: object.property or object[property]
What is the purpose of variables?
To store values to the variable so we can reuse it
How do you declare a variable?
var keyword variableName
How do you initialize (assign a value to) a variable?
= (assignment operator) valueOfVariable (on right of variable declaration)
What characters are allowed in variable names?
numbers, letters, $, period, underscore
What does it mean to say that variable names are “case sensitive”?
Variable names must be cased consistently
What is the purpose of a string?
To be used with text
What is the purpose of a number?
To be used with calculations, to store numerical values
What is the purpose of a boolean?
On/off switch. To determine to run script or not. Useful when code has multiple paths
What does the = operator mean in JavaScript?
Assigment operator, assigns value to variable
How do you update the value of a variable?
variableName = newValue;
What is the difference between null and undefined?
Null- intentional absence of value by user
Undefined- value does not exist according to computer
Why is it a good habit to include “labels” when you log values to the browser console?
Gives value context and indicates what that value is
Give five examples of JavaScript primitives.
string, number, boolean, undefined, null
What data type is returned by an arithmetic operation?
number
What is string concatenation?
Joining strings end to end with + operator
What purpose(s) does the + plus operator serve in JavaScript?
Addition and concatenation
What data type is returned by comparing two values (, ===, etc)?
boolean
What does the += “plus-equals” operator do?
The += operator adds the value on its right to the variable or property on its left, and assigns the result to the variable or property on its left
What are arrays used for?
To store a collection of data