Created
July 10, 2022 09:08
-
-
Save Akifcan/ce3733dca107c2ca1a292de5070c196d to your computer and use it in GitHub Desktop.
My own map implementation in javascript
This file contains hidden or 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 people = [ | |
{ | |
name: 'akif', | |
status: 'full stack developer' | |
}, | |
{ | |
name: 'sebnem ferah ❤❤', | |
status: 'artist' | |
}, | |
] | |
Array.prototype.myMap = function(cb){ | |
const output = [] | |
this.forEach((x, i) => { | |
output.push(cb(x, i)) | |
}) | |
return output | |
} | |
const x = people.myMap((c, i) => { | |
return ({ | |
"isim": c.name, | |
"durum": c.status | |
}) | |
}) | |
console.log(x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment