JavaScript Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is the default prototype of a function?

A

an object with the only property constructor that points back to the function itself.

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

What is a prototype in JavaScript?

A

Prototypes are the mechanism by which JavaScript objects inherit features from one another

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

What is a class in JavaScript?

A

Syntactic sugar for JavaScript’s existing prototype-based inheritance

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

What is the final link in any JavaScript Object’s prototypal chain?

A

technically, null, but `Object’ sits at the top of any JavaScript Object’s prototypal chain.

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

What are JavaScripts 5 Primitive Data Types?

A

Number, String, Boolean, Undefined, Null

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

What is NaN in JavaScript?

A

Stands for ‘Not a Number’ - it is the result of any illegal numerical operations.

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

What are Falsy values in JavaScript?

A

0, “”, null, false, undefined, NaN

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

What is a Primitive Data Type?

A

Data that is not an object and cannot have methods.

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

What are the 5 different ways to declare variables or constants in JavaScript?

A

var, let, const, window, and global.

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

What is the difference between var, let and const?

A

[var] - is function scoped, meaning that it will be hoisted to the top of the function in which it is defined.
[let] - is block scoped. meaning that it will be only be hoisted to top of the block in which it is declared.
[const] - used to declare constants. They cannot be redeclared, but they can be reassigned.

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

What are the three different ways to declare a function in JavaScript?

A
1. Function-Style:
function functionName(arg1, arg2, arg3, argN) {
  // code block...
}
2. Expression-Style:
const functionName = function (arg1, arg2, arg3, argN) {
  // code block...
};
3. Fat-Arrow Style:
const functionName = (arg1, arg2, arg3, argN) => {
  // code block...
};
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is a callback in JavaSrcipt?

A

A function that is passed to another function as an argument.

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

What is a closure in JavaScript?

A

an inner function that has access to the outer (enclosing) function’s variables—scope chain.

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

What is the difference between a pure and impure function?

A

A pure function is a function which given the same input, will always return the same value and it produces no side effects. An impure function is a function that mutates variables/state/data outside of it’s lexical scope.

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

What is the new keyword?

A

The new keyword invokes a function in a special way. Functions invoked using the new keyword are called constructor functions.

  1. Creates a new object.
  2. Sets the object’s prototype to be the prototype of the constructor function.
  3. Executes the constructor function with this as the newly created object.
  4. Returns the created object. If the constructor returns an object, this object is returned.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are the main differences between ES5 and ES6 JavaScript?

A
  1. Block Scoping
  2. Lexical “this” (via Arrow Functions)
  3. Dealing With “arguments” - in ES5 arguments were like an array, but not an array. In ES6, by using …args, args is an array.
  4. Classes - JS doesn’t support the “Classes” and just simulates it via “prototypes”, it’s syntax has been very confusing for both existing JS developers and new comers who wants to use it in a traditional OO fashion.
  5. Strict Mode - Strict Mode(“use strict”) helps identify common issues (or “bad” parts) and also helps with “securing” JavaScript.