Commit 2aa69e9c authored by Paul Slaughter's avatar Paul Slaughter

Merge branch 'ss/update-parseint-docs' into 'master'

Change strictness of parseInt rule

See merge request gitlab-org/gitlab!22721
parents 9e84a03c f1f38532
...@@ -98,16 +98,27 @@ class a { ...@@ -98,16 +98,27 @@ class a {
} }
``` ```
## Use ParseInt ## Converting Strings to Integers
Use `ParseInt` when converting a numeric string into a number. When converting strings to integers, `parseInt` has a slight performance advantage over `Number`, but `Number` is semantic and can be more readable. Prefer `parseInt`, but do not discourage `Number` if it significantly helps readability.
**WARNING:** `parseInt` **must** include the [radix argument](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt).
```javascript ```javascript
// bad // bad
Number('10') parseInt('10');
// bad
things.map(parseInt)
// ok
Number("106")
// good
things.map(Number)
// good // good
parseInt('10', 10); parseInt("106", 10)
``` ```
## CSS Selectors - Use `js-` prefix ## CSS Selectors - Use `js-` prefix
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment