Classes Flashcards

Get a job

1
Q

What are classes?

A

A template for creating objects. They encapsulate data with code to work on that data.

Classes in JavaScript are built on prototypes but also have syntax and semantics that are unique to classes.

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

What are getters?

A

A method that retrieves the value of a property. To define a getter, the method name must be preceded by the “get” keyword. Also, getters are accessed without parentheses, as if they were properties.

Getters can perform computations or transformations before returning a value.

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

What constitutes the body of a class?

A

Everything enclosed by the curly braces, that’s where class memebers are defined (methods, contructor, etc).

The body of a class is executed in strict mode even without the “use strict” directive.

A class element can be characterized by three aspects:

Kind: getter, setter, method or field.
Location: static or instance.
Visibility: public or private.

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

What is a contructor?

A

A special method for creating and initizalizing an object created with a class. There can only be one special method with the name “constructor” in a class.

A constructor can use the “super” keyword to call the constructor of the super class.

You can create properties inside the constructor.

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

What is a setter?

A

A method defined with the “set” keyword. Binds an object property to a function to be called when there is an attempt to set that property.

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

What are instance variables?

A

An object is an instance of the class that is created from. Instance variable are all of the properties defined in the class for that object (typically inside the constructor). Every instance variable is accesible using “this.” prefix inside any the instance methods.

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

What are private fields?

A

Properties that cannot be accessed from outside the class. They’re created using a “#”.

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

What is inheritance?

A

Inheritance refers to passing down characteristics from a parent to a child so that a new piece of code can reuse and build upon the features of an existing one.

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

What are static methods?

A

Methods that belong to the class itself. They don’t have access to the “this” object.

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

What is super?

A

A keyword used to access properties on an object literal or class’s [[Prototype]], or invoke a superclass’s constructor.

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