An Interest In:
Web News this Week
- April 24, 2024
- April 23, 2024
- April 22, 2024
- April 21, 2024
- April 20, 2024
- April 19, 2024
- April 18, 2024
September 9, 2022 06:54 am GMT
Original Link: https://dev.to/sujithvsuresh/new-generation-syntax-for-javascript-classes-es6-babel-3dp5
New generation syntax for JavaScript classes | ES6 / Babel
A class mainly have properties and methods.
Properties are like 'Variables attached to classes'.
Methods are like 'functions attached to classes'.
Let's take a look at a class which has the new gen syntax,
class Human { gender = 'male'; printGender = () => { console.log(this.gender); }}class Person extends Human { name = "Max"; printMyName = () => { console.log(this.name); }}
Here we exclude the constructor function and directly assign the value to a variable inside the class.
And then we use arrow functions syntax to create method inside the class.
Original Link: https://dev.to/sujithvsuresh/new-generation-syntax-for-javascript-classes-es6-babel-3dp5
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To