Search code examples
javascriptsafari

Unexpected use of reserved word 'let' in strict mode


I'm getting an error when I test the following code in Safari.

var temp_color = null;
    var temp = 0;
    var tempv = 0;
    for (let x in colorblock) {
        temp_color = colorblock;
        tempv = Math.pow((color.r - temp_color.r), 2) + Math.pow((color.g - temp_color.g), 2) + Math.pow((color.b - temp_color.b), 2);
        if (x === 0) {
            temp = tempv;

Safari throws the error "Unexpected use of reserved word 'let' in strict mode" but it does work when I use Chrome.


Solution

  • let is not supported in Safari 9 or iOS Safari 9.2:

    http://caniuse.com/#search=let