![](/img/trans.png)
[英]how can i change firstname/lastname to firstName/lastName in react? the problem is that it comes from the backend
[英]How can I add firstName and lastName to fullName?
person = { firstName: 'Joseph', lastName: 'Magnolia', ageInYears: 34 }
function addFullName(personObj) {
person = { fullName: firstName + lastName, ageInYears: 34, }
}
它告诉我undefined
,我尝试了不同的东西。
你的代码没有任何意义,但你的意思是这样的:
var person = { firstName: 'Joseph', lastName: 'Magnolia', ageInYears: 34 }; addFullName(person); console.log(person); function addFullName(personObj) { personObj.fullName = personObj.firstName + ' ' + personObj.lastName; }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.