[removed] How can I transform an array?

前端 未结 6 958
-上瘾入骨i
-上瘾入骨i 2021-01-12 05:10

I have this on a javascript var: (it\'s a http returned data, and I don\'t know if it\'s an array or string - (how can we see that?) - Update: using typeof returned \"string

6条回答
  •  半阙折子戏
    2021-01-12 05:42

    This question is strongly related with this one.

    I would suggest reading my answer there, as it would really help; and with a little variation, it would just work:

    var responseString = '[{"nomeDominio":"gggg.fa"},{"nomeDominio":"rarar.fa"}]',
        responseObject = JSON.parse(responseString),
        nombresDeDominio = [];
    
    for(var i in responseObject) {
      nombresDeDominio.push(responseObject[i].nomeDominio)
    }
    

    Suerte!

提交回复
热议问题