我有将数字转换为字符串的情况。在下面的函数中。我正在迭代对象并尝试更改plan_price. 当我执行 console.log() 时它正在工作 bestPlanArrange(bridals){ let plans = []; bridals.filter(item => { item.plans.filter(plan => { plans.push(plan); }); }) let obj = {} let planArr = []; plans.filter(item => { item.plan_price.toString() console.log(item.plan_price) // doesn't listen the code above not working. console.log(item.plan_price.toString()) // it's working like this. planArr.push(item) // I want to push after covert. }) if (planArr[0] != null && plans[0].plan_price != null) { obj = planArr[0]; } return obj; },我在这里遗漏了什么或做错了什么吗?
1 回答
largeQ
TA贡献2039条经验 获得超7个赞
调用toString()
不会更改适当的值。您必须将结果分配回变量:
item.plan_price = item.plan_price.toString()
添加回答
举报
0/150
提交
取消