Tuesday, June 4, 2024
 Popular · Latest · Hot · Upcoming
137
rated 0 times [  140] [ 3]  / answers: 1 / hits: 21454  / 12 Years ago, tue, may 1, 2012, 12:00:00

As a case study, I am trying to get to grips with this code snippet that uses the parseInt() function, and have a couple questions:


var maxChars = parseInt( formField.attr('maxlength') ? formField.attr('maxlength') : counter.text() );


  • Why is formField.attr('maxlength') there twice?



  • How does a Radix parameter work in this example?




More From » parseint

 Answers
74

The radix is another name for base, i.e. 2 for binary, 10 for decimal, 16 for hexadecimal, explained in more detail on the Mozilla Developer Network site.



In your example there is no radix parameter, so the interpreter will fall back to the default behaviour, which typically treats numbers as decimal, unless they start with a zero (octal) or 0x (hexadecimal).


[#85867] Monday, April 30, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
sylviakaitlinj

Total Points: 564
Total Questions: 114
Total Answers: 105

Location: Jordan
Member since Thu, Aug 11, 2022
2 Years ago
sylviakaitlinj questions
;