如何在 Arrow function
中获取值,它在对象内部。
我想访问该对象的其他属性。
let obj = {
name:'Ashu',
age:123,
show: ()=>{
// I want to print Name and Age how to do that
// Is there any other way to do get Name and Age Property
// I don't want to replace the Arrow function
console.log(obj.name, obj.age);
}
}
obj.show()
最佳答案
这应该有效:
let obj = {
name: 'Ashu',
age: 123,
show: () => {
console.log(obj.name, obj.age);
}
}
obj.show();
关于javascript - 如何在箭头函数中获取值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64657025/