Roger Dodger
Roger Dodger

Reputation: 987

Javascript For ... of loop in array not working in safari 5.1.7

I've got a for..of javascript loop to loop through an array. My code snippet works fine in Chrome, IE & Firefox consoles without any problems but fails in the safari (version5.1.7) console. I get the following error:

line: 287
message: "Expected an identifier but found 'arr' instead"
sourceId: 2082538144
__proto__: Error

My code snippet is pretty simple and is as follows:

let arr = [11, 22, 34, 45, 66, 77, 88];

for(let elem of arr){
  console.log(elem);
  if(elem > 50){
    break;
  }
}

Has anyone else faced this issue and solved it?

Upvotes: 1

Views: 455

Answers (1)

Nisarg Shah
Nisarg Shah

Reputation: 14561

According to MDN, for...of is supported from Safari 8 onwards.

So that might explain why it doesn't work with your Safari 5.

Upvotes: 4

Related Questions