Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object.prototype,map #589

Open
luo29 opened this issue Mar 29, 2024 · 0 comments
Open

Object.prototype,map #589

luo29 opened this issue Mar 29, 2024 · 0 comments

Comments

@luo29
Copy link

luo29 commented Mar 29, 2024

`
Object.prototype.map = function(callback){
if(typeof callback !== "function"){
throw new TypeError("param must be a Function")
}
const newObj = {}
for(const key in this){
if(this.hasOwnProperty(key)){
newObj[key] = callback(this[key],key,this)
}
}
return newObj
}

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant