Skip to content

Conversation

@DannyNemer
Copy link
Contributor

Clarifies when to use Number vs. parseInt for Number type casting, encouraging the proper usage of both.

Fixes: #523

Previously, at item 21.3, the guide read:

Use parseInt for Numbers and always with a radix for type casting.

However, the example displays:

// good
const val = Number(inputValue);

// good
const val = parseInt(inputValue, 10);

Issue: It is unclear whether Number is acceptable because the guide only directly states to use parseInt despite the example for Number. Indeed, Number and parseInt are not interchangeable and should both be used properply.

README.md Outdated
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could this say parsing strings, and also continue to say always with a radix?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Clarifies when to use `Number` vs. `parseInt` for Number type casting.

Fixes: #523
@ljharb
Copy link
Collaborator

ljharb commented Sep 25, 2015

👍 this LGTM

ljharb added a commit that referenced this pull request Sep 25, 2015
Clarify proper type casting for Numbers
@ljharb ljharb merged commit d14e8b7 into airbnb:master Sep 25, 2015
@DannyNemer DannyNemer deleted the patch-1 branch September 25, 2015 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants