phetsims / perennial

Maintenance tools that won't change with different versions of chipper checked out
MIT License
3 stars 5 forks source link

Number() vs. parseInt() #275

Closed marlitas closed 2 years ago

marlitas commented 2 years ago

This issue comes from a discussion in: https://github.com/phetsims/perennial/issues/274

What is the best string => number conversion for PhET usage. A couple of things to note that have come up from initial discussions/research:

Historically PhET devs have preferred parseInt(), should that change?

zepumph commented 2 years ago

When converting, let's also remember to search for parseFloat, and Number.parseInt.

marlitas commented 2 years ago

@jbphet discovered an infinite loop in Expression Exchange that we traced back to another inconsistency between parseInt() and Number(). Below screenshot demonstrates the issue as it relates to Expression Exchange.

Image

PSA: Number( '' ) => 0 vs. parseInt( '' ) => undefined

zepumph commented 2 years ago

From dev meeting today. @marlitas is still chipping away at this. Moving to subgroups

marlitas commented 2 years ago

Conversion done. Will leave issue open for a few days in case something comes up that I didn't see in testing.

marlitas commented 2 years ago

I did not find any CT errors related to the Number() conversion in the last few days. Closing