The arrow method is added to JavaScript in ES6 (Think different versions of JavaScript). It has some benefits. One of which is that it is shorter than your typical method.
// typical method
function powerTwo(num) { return num * num; }
// arrow method
let powerTwo = (num) => num * num;
const let methodName = (Parameter1, Parameter2, ...) => { /* */ };
// note: if you don't use brackets, it is implied that whatever comes after the
// arrow is something you want to return.
There are some downsides to arrow methods:
You can add practice problems here if you want. Follow the format below.
6.3 Difference Between Arrow and Regular Method
<aside> ⚖️ Copyright © 2021 Code 4 Tomorrow. All rights reserved. The code in this course is licensed under the MIT License.
If you would like to use content from any of our courses, you must obtain our explicit written permission and provide credit. Please contact [email protected] for inquiries.
</aside>