JavaScript Flashcards
What are JavaScript’s primitive data types?
Boolean, BigInt, Null, Number, String, Symbol, Undefined
What does the Number data type include?
All real numbers (positive and negative integers and floating point numbers, +/-Infinity)
What is a string?
Strings are a list of characters in a specific sequence surrounded by single or double quotes.
What is a Boolean?
Primitive data type which has the values of true or false.
What does a value of null represent?
Represents the intentional absence of a value.
The value of undefined represents…?
Represents the absence of a value and is used to convey the value does not exist.
What is an Object?
Collection of related data as key : value pairs.
Which values evaluate as falsy?
0, -0, 0n (BigInt zero) empty strings, null, undefined, NaN, false
What is an object property?
A property is a member of an object that associates a key with a value.
What is a method?
A method is a function which is associated with an object’s property.
What do comparison operators return?
A Boolean value of true/false
<, >, <=, >=, ==, ===, !=, !==
Three ways to define a function in JavaScript:
Function declaration.
Function expression.
Arrow function (also known as arrow function expressions)
Key difference between a function declaration and function expression?
Function expressions are not hoisted and cannot be called before they appear in a program.
What is an anonymous function?
A function with no name property.
When would you use a do/while statement?
When you want the code block to execute at least 1 time.
Functions that always return a true or false value are referred to as…
Predicates
What is function composition?
Passing a function call as an argument to another function.
[].includes()
An array prototype method that determines if a value passed as an argument is an element of the calling array and returns true or false as appropriate.
[].slice()
An array prototype method which returns a portion of an array into a new array object selected from index start up to but not including index end. If no index end argument is given, the method will automatically slice to the final element of the array.
.splice()
Changes the contents of an array by removing or replacing existing elements and/or adding new elements. Returns an array of the deleted elements. Argument format is:
splice(startIndex, deleteCount, item1, item2, itemN)
.push()
Adds one or more elements to the end of an array and returns the new length of the array.
.pop()
Removes the last element from the array and returns the removed element.
.join()
Creates and returns a new string by concatenating all of the elements in the array. If no separator argument is passed the elements will be comma separated with no spaces between elements.
[].concat()
Merges two or more arrays and returns a new array.
```[1, 2].concat([3])
~~~
\\ returns a new array [1, 2, 3]