JavaScript - Basics Flashcards
ECMA Script is
The standard for javascript
A variable is not a value, but …
it points to a value
When naming a variable, it must start with…
a letter
When creating a variable we use the case convention called
camelCase
The difference between let and const is…
let creates variables that can have the value reassigned, const for the variables that shouldn’t be reassigned
The two categories of data types are
Primitives (immutable) and non-primitives (mutable)
The 7 primitive data types are:
string, number, bigint, boolean, undefined, null and symbol
The non-primitive data type is:
objects
If… else and switch statements are:
conditional statements
&& means
and
|| means
or
What is the syntax of a ternary operator?
condition ? return if condition is true : return if condition is false
A function is
a block of code that can be reused
What’s the difference between parameters and arguments?
parameters are defined when we create the function, arguments is the value we pass when calling the function
The return statement will
stop the execution of the function and give a value in return
How do I access the first element of const myArr = [“Ana”, 32, true]
myArr[0]
How do I check the length of the array const myArr = [“Ana”, 32, true]
myArr.length
What is a higher order function?
a function that accepts another function as the argument
What is a callback function?
a function that is passed as the argument to another function (a higher order function)
Are arrays a data structure?
Yes
When creating a for loop, what are the 3 statements necessary?
initial value, condition to meet, what to do after each loop
What’s the difference between a while loop and a do while loop?
the while loop will always check the condition first and only run if condition is met, the do while loop will run the code once, then check the condition on the following loop
If a condition of a loop is never met, what happens?
We create an infinite loop
What does DOM stands for
Document Object Model
If I want to target something by its ID, which method do we use?
document.getElementById(“idToTarget”)
What happens when we use the innerHTML property?
we have access the content of a node element
How can we create new HTML elements?
document.createElement(‘elementTag’)
What is the spead operator used for? const numbersArray = [1, 2, 3]
spread out elements of an iterable object
console.log(…numbersArray) //1 2 3
What is the value of rest? const numbers = [13, 23, 43, 54, 15] const [a, b, ...rest] = numbers
[43, 54, 15]