1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
Index: /Users/jan/webdev/moodev/mootools/trunk/Native/String.js
===================================================================
@@ -38,6 +38,9 @@
/*
Property: toInt
parses a string to an integer.
+
+ Arguments:
+ base - Integer, optional; base to use, defaults to 10
Returns:
either an int or "NaN" if the string is not a number.
@@ -46,8 +49,8 @@
>var value = "10px".toInt(); // value is 10
*/
- toInt: function(){
- return parseInt(this, 10);
+ toInt: function(base){
+ return parseInt(this, base || 10);
},
/*
Index: /Users/jan/webdev/moodev/mootools/trunk/Native/Number.js
===================================================================
@@ -16,10 +16,17 @@
/*
Property: toInt
Returns this number; useful because toInt must work on both Strings and Numbers.
+
+ Arguments:
+ base - Integer, optional; base to use, defaults to 10
+
+ Example:
+ (111).toInt() // returns 111
+ (111).toInt(2); // returns 7
*/
- toInt: function(){
- return parseInt(this);
+ toInt: function(base){
+ return parseInt(this, base || 10);
},
/*
|