JavaScript Flashcards

1
Q

What is prototypical inheritance and why is it useful?

A

The idea that every object in JS has a prototype from which it inherits values and behaviours. If an object doesn’t include a property that’s being requested, JS will look for it inside its prototype. Prototypical inheritance is useful when making objects that share the same values and operations, so that only one copy of the prototype object exists.

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

What is event capturing and event bubbling?

A

In event capturing, the parent element will capture the event first and then propagate it to the child elements. In event bubbling, the child element will capture the event first and then propagate it to parent elements.

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

What does the term ‘hoisting’ mean?

A

Hoisting is JavaScripts default behaviour of moving all function and variable declaration to the top of the current scope before code execution.

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

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

A

A const variable cannot be redeclared or updated. A let variable can be updated but cannot be redeclared (unless within a different scope). A var variable can be redeclared and updated.

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

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

A

A const variable cannot be redeclared or updated. A let variable can be updated but cannot be redeclared (unless within a different scope). Both let and const have block scope. A var variable can be redeclared and updated, and has global/function scope.

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

What is a pure function?

A

Pure functions are functions that are not affected by any data outside the scope of that function. Pure function return the same values given the same parameters/arguments.

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

What is functional programming?

A

Functional programming focuses on creating programs by passing application state exclusively through functions. This means all work but be done inside pure functions, and any state within an application should be passed as a parameter to a function.

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

What is an asynchronous function?

A

An asynchronous function is a function which operates asynchronously via the event loop and using and uses an implicit Promise to return the result. In an AF an await keyword is used to the pause the execution of the async function and wait for the passed promise’s resolution before resuming the remainder of the function.

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

What is “strict mode” and how can we apply it to our code?

A

Strict Mode prompts JavaScript to display all errors and warnings, even if they are silent. To enable Strict Mode, add “use strict” to the beginning of the script.

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

What is “strict mode” and how can we apply it to our code?

A

Strict Mode prompts JavaScript to display all errors and warnings, even if they are silent. To enable Strict Mode, add “use strict” to the beginning of the script, program or function.

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

What is the difference between “null” and “undefined”

A

Null is returned when you are accessing a variable that has been assigned the value of null, whilst undefined is returned when accessing a variable that has not been assigned a value.

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

What is the difference between function declaration and function expression?

A

Function declaration is the normal process of defining a function using the keyword function. However, once you assign a function declaration to a variable then it becomes a function expression.

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

What are three common JavaScript frameworks and what are they used for.

A

React, Vue and Angular are commonly used frameworks and are used to build web interfaces.

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