-
-
Save vmarchesin/df50cb8692918557379b54aa03cd3e05 to your computer and use it in GitHub Desktop.
Javascript Arrow Functions and Closure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const movies = [ | |
{ rating: 8.4, title: 'The Shining' }, | |
{ rating: 8.3, title: 'Reservoir Dogs' }, | |
{ rating: 6.2, title: 'Alien vs Predator' } | |
] | |
// Using the function keyword | |
movies.sort(function (a, b) { | |
return a.rating - b.rating | |
}) | |
// Using the arrow function syntax | |
movies.sort((a, b) => a.rating - b.rating) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment