-
Notifications
You must be signed in to change notification settings - Fork 163
[JavaScript] Add new concept exercise: classes-intro #1390
Conversation
NOTE: THIS IS STILL A DRAFT |
Things left to do:
|
Testing is all done. Now I just need to add in all the instructions |
/format |
@rishiosaur The main reviewer for the JavaScript track (@SleeplessByte) is temporarily unable to do reviews. It might take a little longer for this to be reviewed. Thanks for the patience! |
No worries @ErikSchierboom! |
|
||
``` | ||
|
||
To add a method (a function of a class) to a class, just write the function definition without the `function` keyword in the class body: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would remove the use of "just"
To add a method (a function of a class) to a class, just write the function definition without the `function` keyword in the class body: | ||
|
||
```js | ||
class FunctionDemo { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would see this easier to understand without using the word 'function' in the class name and the methods.
|
||
The `this` keyword is a way to access properties and methods on a class's _prototype_. The prototype is a JavaScript object where all properties and methods of a class are stored. | ||
|
||
You can access the `this` keyword from anywhere inside any function: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would make it clear that "any function" is "any function" that is on the class
console.log(this.property1) | ||
} | ||
|
||
myFunction() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would remove the word Function here. Also, is this a time to discuss when to call it a function and when to call it a method?
This Friday (Jan 29th 2021), we're going to explode this repo back into the individual track repositories and archive this repo. As such, this PR needs to be merged by Friday 9am UTC, or it will need to be manually reopened against the track repo. |
@rishiosaur if possible, can you rebase? If not I can do it later. |
This PR brings in the implementation described in #1325.