Home>

The following is a part of vuex mutations, but the data obtained from Firestore by actions is stored in the argument uploadContents.
This uploadContents is an array of objects with about 10 properties, and since it was necessary to process this with a for statement, I wrote a process to output to the console once in the for statement, but in the first place for It doesn't seem to pass the sentence.

setMyUploadContents (state, uploadContents) {
      console.log (uploadContents)
      for (let content of uploadContents) {
        console.log (content);
      }
    },

Is it possible to use for of for an array of objects in JavaScript?
I would like to know how to fix it in this case.

  • Answer # 1

    The for of itself should work.

    Reference: MDN | for ... of

    If it does not fit in foruploadContentsI don't think it's iterable.
    Immediately beforeconsole.log (uploadContents)Is it output correctly?