read name of unknown properties

后端 未结 2 585
故里飘歌
故里飘歌 2020-12-06 20:07

I have a simple javascript object with several unknown properties containing a value. The problem is that i don\'t really know the name of the field since it is variable. Ho

2条回答
  •  臣服心动
    2020-12-06 20:46

    You could access the properties by name:

    for (var key in a) {
        var value = a[key];
    }
    

    Demo.

提交回复
热议问题