+ 5
i didn't understand the line 4 of this code. please help me
6 Respostas
+ 3
Perhaps you have learned about methods. Another term for a method is a member function. A method is similar to a function, but it operates on the data of the object in which it belongs.
In the example you have provided, the print method is an arrow function defined using the ES6 arrow function syntax ()=>{}.
this.print = () =>{ console.log(this.name+": "+this.number);
}
In ES5, you can define the method using regular function syntax.
function() {};
this.print = function() { console.log(this.name + ": " + this.number);
}
+ 3
You will learn about arrow functions later in our JS course. You may find it helpful to use other resources as they may explain things more thoroughly. As Ipang mentioned, Mozilla.org is a helpful resource to further your knowledge while learning here on Sololearn. However, their detailed instructions can seem overwhelming for beginners.
+ 2
You might find this page helpful as an intro to arrow functions
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions
+ 2
+ 1
Hi Kenny S. Otero Maisonet Rahul Pandey iMRAN KHAN. If you have a question please create a new post so that we can help you with out distraction.Thank you.