i didn't understand the line 4 of this code. please help me | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

i didn't understand the line 4 of this code. please help me

https://code.sololearn.com/WECoaebZlCfR/?ref=app

17th Feb 2023, 3:05 AM
Naimul Hasan
Naimul Hasan - avatar
5 Answers
+ 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); }
17th Feb 2023, 6:04 AM
Chris Coder
Chris Coder - avatar
+ 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.
17th Feb 2023, 6:20 AM
Chris Coder
Chris Coder - avatar
+ 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
17th Feb 2023, 6:09 AM
Ipang
+ 2
Mirielle , Ipang and Chris Coder thank you guys.
17th Feb 2023, 8:38 AM
Naimul Hasan
Naimul Hasan - avatar
+ 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.
19th Feb 2023, 2:53 AM
Chris Coder
Chris Coder - avatar