Is there a performance difference between 'let' and 'var' in JavaScript

前端 未结 5 1360
慢半拍i
慢半拍i 2020-11-28 05:23

The difference between these two keywords in terms of scoping has already been thoroughly discussed here, but I was wondering if there is any kind of performance difference

5条回答
  •  渐次进展
    2020-11-28 05:54

    FYI; After Chrome v60, no further regressions have cropped up. var and let are neck and neck, with var only ever winning by less than 1%. Real world scenarios sometimes give var an advantage due to hoisting and re-use, but at that point you're comparing apples to oranges, as let is intended to allow you to avoid that behavior because the semantics are different.

    Benchmark. Firefox, IE and Edge like let just fine.

提交回复
热议问题