• Home
  • Jobs
  • Courses
  • Questions
  • Teachers
  • For business
  • ES/EN

0

17
Views
Safari and WebKit async anonymous function execution differences

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?

about 1 month ago ·

Juan Pablo Isaza

Answer question
Find remote jobs
Loading

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post job Plans Our process Sales
Legal
Terms and conditions Privacy policy
© 2022 PeakU Inc. All Rights Reserved.