Updating javascript object property?

后端 未结 8 1846
盖世英雄少女心
盖世英雄少女心 2021-02-01 03:26

I have a structure like the following:

skillet.person = {
  name: {
    first: \'\',
    last: \'\'
  }, 
  age: {
    current: \'\' 
  },
  birthday: {
    day:         


        
相关标签:
8条回答
  • 2021-02-01 03:52
    skillet.person.name.first = "blah"
    skillet.person.name.last = "ha"
    

    The easiest way.

    0 讨论(0)
  • 2021-02-01 03:55

    push is a method of Arrays that adds a new item to an array.

    If you want to replace the value then:

    skillet.person.name = { … };
    

    If you want to store multiple (full) names in the object, then you'll need the property to hold an array of objects instead of a single object.

    0 讨论(0)
提交回复
热议问题