JavaScript: The Good Parts Flashcards

1
Q

What is loose typing in JavaScript?

A

Loose typing means that JavaScript allows variables to hold values of different types, and the language automatically converts between types as needed.

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

What does it mean for functions to be first-class objects in JavaScript?

A

Functions as first-class objects means that functions can be assigned to variables, passed as arguments, and returned from other functions, just like any other data type.

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

What is prototypal inheritance in JavaScript?

A

Prototypal inheritance is a type of inheritance in which objects inherit directly from other objects, rather than inheriting from a class or blueprint.

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

What is the role of whitespace in JavaScript?

A

Whitespace is usually not significant and is ignored during execution.

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

What are objects in JavaScript?

A

Objects in JavaScript are collections of key-value pairs, where keys are strings and values can be any data type, including other objects, functions, and arrays.

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

How can objects be created in JavaScript?

A

Objects can be created using object literals, the new keyword with a constructor function, or the Object.create() method.

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

What is the prototype chain in JavaScript?

A

The prototype chain is a mechanism through which objects can inherit properties and methods from other objects, by having a reference to their prototype object.

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

What is inheritance in JavaScript?

A

Inheritance in JavaScript is a mechanism that allows objects to share properties and methods with other objects. JavaScript implements prototypal inheritance, where objects inherit directly from other objects.

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

What is a prototype object in JavaScript?

A

A prototype object is an object from which other objects can inherit properties and methods. Every JavaScript object has an internal reference to a prototype object, which forms a prototype chain that ultimately leads to the root object.

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

How can you set the prototype of an object in JavaScript?

A

You can set the prototype of an object by using the Object.create() method to create a new object with a specified prototype or by assigning a constructor function’s prototype property before creating new instances with the new keyword.

Example: var childObject = Object.create(parentObject);

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

What is the role of the this keyword within methods in JavaScript?

A

The this keyword within a method refers to the object on which the method was invoked. It allows methods to access and manipulate the object’s properties and other methods.

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

How do you add a method to a prototype in JavaScript?

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