As seen in the post Variety of coding and coding approaches that a developer may have to solve a problem are multiple and diverse for the same programming language used. Here's how some of the most popular JavaScript frameworks have solved a simple function of CamelCase :
Prototype.js
Prototype.js , version 1.6.0.3, explicitly proposes a method camelize() to make the camelcase on a string. The author's approach is quite simple and the code is self-explanatory. In this case it was not made any use of Regular Expression!
1 2 3 4 5 6 7 8 9 10 11 12 13 | ( ) { camelize: function () { this . split ( '-' ) , len = parts. length ; var parts = this. split ('-'), len = parts. length; len == 1 ) return parts [ 0 ] ; if (len == 1) return parts [0]; this . charAt ( 0 ) == '-' camelized var = this. charAt (0) == '-' 0 ] . charAt ( 0 ) . toUpperCase ( ) + parts [ 0 ] . substring ( 1 ) ? Parts [0]. CharAt (0). ToUpperCase () + parts [0]. Substring (1) 0 ] ; : Parts [0]; var i = 1 ; i < len ; i ++ ) for (var i = 1, i <len; i + +) i ] . charAt ( 0 ) . toUpperCase ( ) + parts [ i ] . substring ( 1 ) ; camelized + = parts [i]. charAt (0). toUpperCase () + parts [i]. substring (1); camelized return; } |






Latest Comments
Robert : I rispsoto your questions with pleasure. The idea is really great. I am looking for a solution ...
Sting : @ Darius - you can see an example here: http://www.fight4fun.it/ clicking on: MAPS I hope ...
vik : Giustappunto I'm working on a project and the client asked me to show all the news (which are CPT) in ...
Giovambattista Fazioli : @ paso: absolutely. Simply identifying the field [cci] input [/ cci] you want to ...
paso : Hello I would like to request a service, you can use the datepicker with cform7 I spiegp best I can implement ...