who can help me eyeball this small piece of code

问题: I have a few lines of code which seems pretty simple, but just doing something unexpected, appreciate if you could eyeball it for me and give me a hint. there are two con...

问题:

I have a few lines of code which seems pretty simple, but just doing something unexpected, appreciate if you could eyeball it for me and give me a hint.

there are two console.log in the code and the output of them are in the picture attached, the first log shows they are holding some values, and the second suggests that they don't ( assignment doesn't work), just can't see how those lines in between could affect.

notes: some commented lines in between have been removed for clearity.

  const { password, confirmPassword, role, position, ...rest } = this.state.data
  console.log(role.value, position.value)
  let dataToSave
  if (this.state.isPasswordChanged) {
      dataToSave = { password, roleID: role.value, positionId: position.value, ...rest 
  }
  else {
        dataToSave = { roleID: role.value, positionId: position.value, ...rest }
  }
  console.log(dataToSave)

enter image description here


回答1:

(Perhaps I might normally like to write this proposed observation as a comment but I still need a higher reputation score to be able to write comments.)

I don't see how "5c4459e47afe0821c4790637" shows that position.value ever had a value, and I'm thinking that it never did and you need to find out why.

  • 发表于 2019-01-23 08:28
  • 阅读 ( 234 )
  • 分类:网络文章

条评论

请先 登录 后评论
不写代码的码农
小编

篇文章

作家榜 »

  1. 小编 文章
返回顶部
部分文章转自于网络,若有侵权请联系我们删除