Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • 2
    How does this add anything? There are several older answers that have already provided these approaches. Please read existing answers before posting. Commented Apr 12, 2020 at 3:34
  • He is showing the efficiency of one is greater than the efficiency of the other. Commented Oct 8, 2021 at 17:05
  • 2
    @user1644002 - Well if he (and you) think that, then he is (probably) incorrect. The JIT compiler should inline the valueOf -> parseInt call making the two versions equally efficient. Commented Jan 2, 2022 at 1:55