JavaScript Flashcards

1
Q

What is a Promise?

A

An object that allows a function to handle asynchronous operations (like fetching data)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is DOM manipulation?

A

When JavaScript is used to add, remove, and modify HTML elements.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the 5 primitive data types in JavaScript?

A

A primitive is a data type that isn’t composed of other data types. They are:
* Boolean
* Undefined
* Null
* Number
* String

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How is the this keyword used?

A

The this keyword refers to the object that the function is a property of.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is hoisting?

A

The default behaviour of JavaScript, where all the variable and function declarations are moved to the top of the file during runtime.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a higher order function?

A

Functions that either (1) take other as arguments or (2) returns other functions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a closure?

A

It’s an ability of a function to remember the variables and functions that are declared in its outer scope.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How can OOP be implemented in JavaScript?

A

OOP is a programming style where functions and variables are organised in objects. It can be implemented in JavaScript through regular objects or classes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the difference between var, let and const keywords?

A
  • Scope
    • “var” is scoped to the function in which they are created, or if created outside of any function, to the global object. “
    • let” and “const” are block scoped, meaning they are only accessible within the nearest set of curly braces (function, if-else block, or for-loop).
  • Hoisting
    • “var” is hoisted and initialized at runtime
    • “let” and “const” are hoisted but not initialized at runtime.
  • Assignment
    • “var” and “let” can be reassigned
    • “const” cannot be reassigned
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What does pass by reference or pass by value mean?

A
  • Primitive data types (like numbers, strings or booleans) are passed by value.
  • Non-primitive data types (like objects or arrays) are passed by reference.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is prototypal inheritance?

A

All JavaScript objects have a __proto__ property (with the exception of objects created with Object.create(null)). This __proto__ is a reference to another object, which is called the object’s “prototype”.

When a property is accessed on an object and if the property is not found on that object, it will go down the “prototypal chain” until it finds the original prototype.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly