JS Basics Flashcards
What are the primitive data types?
Numbers, Strings, Boolean Values
What are the composite data types?
Objects, Functions, Arrays, JavaScript Object Literals
What is a data type?
A general term to describe categories of values that a program or programming language can make use of.
What is the Number Data Type?
A numeric value
What is the String Data Type?
A sequence of valid characters usually used for text surrounded by quotes.
What is the Boolean Data Type?
A true or false value.
What is a switch statement?
Allows you to set a number of options (cases) and check an expression to see if it matches any of them. If no match is found it returns the default action.
What does && do?
AND, Returns true if both conditions are true.
What does || do?
OR, Returns true if one or both of the conditions are true.
What is a heterogeneous array?
An array with mixed data types.
What is a jagged array?
Jagged arrays are when you have 2 dimensional arrays of varying length
What is a 2 dimensional/multidimensional array?
An array that has an array inside of it
What type of object syntax is: var obj = { } ?
Object Literal Syntax
What type of object syntax is: var obj = new Object( ); ?
Object Constructor Syntax
What is a property?
A variable associated with an object
What is a method?
A function (action) associated with an object
What does myObj.hasOwnProperty(“name”); do?
Checks to see if the object myObj has a property called name and returns true if it does.
What does for(var myProp in places){} do?
Runs the code for all properties in the object places all at once.
What does for(var x in blank) {
console.log(blank[x]);
} do?
It will print all the property values for the object blank.
What is a ternary operator?
A ternary operator is often used as a shortcut for the if statement.
What is the syntax of the ternary operator?
condition ? expression1 : expression2
What does the ? and : stand for in a ternary operator?
the ? creates the condition followed by the expression to run if the condition is true. The : creates the second condition to run if it’s false (else{})
What is a function?
A body of code that can be called by other code or by itself, or a variable that refers to the function. (a verb in programming).
When a function is called, arguments are passed to the function as input, and the function can optionally return an output. A function is also an object.