Intro to JavaScript
# Intro to JavaScript
1. Which keywords are used to declare a variable in JavaScript?
Var Let and Const
2
2. What is the definition of a function?
Resuable set of statements to perform an action.
3. What are the SOLID
principles?
Single Responsibility,
Open-closed principle,
liskov substitution principle,
interface segregation principle, and dependency inversion principle.
2
3
4
4. Given this array:
let fruit = ['apple', 'banana', 'pineapple', 'orange', 'strawberry']
What index is the pineapple's current position? How do you know?
The pineapple's current position is [2] because arrays are zero indexed.
5. With these two objects:
let you = { name:"You", hair: true, friends: [] }
let them = { name:"Them", hair: false, friends: [] }
2
how would you .push the them
object into the you
object's array of friends?
you.push(them.name)
2
6. Give an example of a JavaScript Conditional
:
if (10 < 12){
console.log("10 is less than 12" )
}
2
3
4
7. In the for loop
below, what is the name of the piece belongs inside the empty "______" space? What would you put here to increase i
by one on every iteration?
for ( let i = 0; i < arr.length; _______ ) {
//...
2
i++
8. What does the DOM
acronym stand for? Which file is first accessed to render the DOM
?
Document Object Model. The first file to be accessed is the index.HTML file.
9. What are the 9
ECMAScript types as defined by MDN?
Numbers, Strings, Booleans, Undefined, Null, Symbol, objects, arrays, functions
10. When it comes to functions or methods, what is the difference between a parameter
and an argument
?
parameters are the variables you pass into a function while the argument is the action of the function.
2
11. What is the difference between a primitive
value and a reference
value?
primitives store the actual value, while references store the route to the objects they refer to.