Safari and WebKit async anonymous function execution differences

Viewed 66

Running this code on Chrome and Safari would be different. Notice, function is async.

(async function(v) {
    console.log(v)
})('@')

Safari out:

1 - '@'

Chrome out:

1 - '@'

Now it look ok, but what if we add some.

(async function(v) {
    console.log(v)
    var v = v || '#';
    console.log(v)
})('@')

Safari out:

1 - undefined
2 - '#'

Chrome out:

1 - '@'
2 - '@'

There are no more passed V as parameter, its voided even right after function body starts. It seems Safari lefthand operator runs first and replace all passed params with the new ones that are defined in a scope. Is this a bug?

0 Answers
Related