Skip to content

Commit

Permalink
Replaced parseInt by unary plus.
Browse files Browse the repository at this point in the history
  • Loading branch information
MattiSG committed Mar 12, 2012
1 parent 328fefd commit cfb6d4c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions index.html
Expand Up @@ -75,12 +75,12 @@
var a = ["1", "2"];
a.push("3");

a = a.map(function(n) { return parseInt(n, 10); });
a = a.map(function(n) { return +n }); // unary plus operator casts into Number

a.splice(1, 1 /* how much */);
a; // [1, 3]

a.reverse() // [3, 1]
a.reverse(); // [3, 1]

a.unshift(777); // 777
a; // [777, 3, 1]
Expand Down Expand Up @@ -127,7 +127,7 @@
</code></pre></td>

<td><pre><code class="javascript">
var a = ["aaa ", " bbb", " ccc "]
var a = ["aaa ", " bbb", " ccc "];

a.map(function(x) { return x.trim(); }); // ['aaa', 'bbb', 'ccc']
a.map(Function.prototype.call, String.prototype.trim); // ['aaa', 'bbb', 'ccc']
Expand Down

0 comments on commit cfb6d4c

Please sign in to comment.