JavaScript Flashcards
What is the purpose of variables?
A variable is a way to store values.
How do you declare a variable?
Use the reserved keyword var to declare a variable in JavaScript. Syntax: var ; var = ; A variable must have a unique name.
How do you initialize (assign a value to) a variable?
You can assign a value to a variable using the = operator when you declare it or after the declaration and before accessing it
What characters are allowed in variable names?
Start them with a letter, underscore _, or dollar sign $.
After the first letter, you can use numbers, as well as letters, underscores, or dollar signs.
Don’t use any of JavaScript’s reserved keywords.
What does it mean to say that variable names are “case sensitive”?
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?
to represent text rather than numbers
What is the purpose of a number?
to represent and manipulate numbers
What is the purpose of a boolean?
to create true/false statements
What does the = operator mean in JavaScript?
assigns a value to its left operand based on the value of its right operand.
What is the difference between null and undefined
undefined is a type, whereas null an object
Give five examples of JavaScript primitives.
undefined , null , boolean , string and number
What data type is returned by an arithmetic operation?
numeric data
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?
precedes its operand and evaluates to its operand but attempts to convert it into a number, if it isn’t already
What data type is returned by comparing two values (, ===, etc)?
boolean
What does the += “plus-equals” operator do?
adds the value on the right, to the variable on the left, and then assigns that value back into the variable on the left.
What is object used for?
An object is an abstract data type with the addition of polymorphism and inheritance.
What are object properties?
Object properties are defined as a simple association between name and value
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, just like a regular array
How do you remove a property from an object?
delete operator
What are the two ways to get or update the value of a property?
dot notation and square brackets
What are arrays used for?
to store a collection of data
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?
object store different types of data, dont have orders. array store same types of data, have orders.
What number represents the first index of an array?
0
What is the length property of an array?
how many pieces in the array