missing ; after for-loop initializer in Javascript

167 views Asked by At
for (var i = 0; i < vms.length; i++){
    for (var [key, value] of Object.entries(vms[i])){
        System.log(key, value);
    }
}

So here is my code, knowing that "vms" is a list of dictionaries. I'm getting the "missing ; after for-loop initializer" error and I don't really know why. I've already been searching here for some answers and the only answers I saw was to use var but I already do...

1

There are 1 answers

1
Bharathi Mohan On

Only the array have length property not dictionaries in javascript. Dictionary is considered as an object. You can use below code to iterate the dictionary key value pair.

for (var [key, value] of Object.entries(vms)){
console.log(key, value);
}