var numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; | |
// Giả sử ta muốn tìm các số chẵn | |
// Cách viết cũ | |
var odd = numbers.filter(function(n) { return n % 2 == 1 }); | |
console.log(odd); | |
// Với arrow | |
odd = numbers.filter(n => n % 2 == 1); | |
console.log(odd); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment