Built-In Namespace: String
Field Summary
Instance Methods
Field Detail
String trimTrims whitespace from either end of a string, leaving spaces within the string intact. Example:
var s = ' foo bar ';
alert('-' + s + '-'); //alerts "- foo bar -"
alert('-' + s.trim() + '-'); //alerts "-foo bar-"
Defined in: aloha.js.
Instance Method Detail
toggle
Utility function that allows you to easily switch a string between two alternating values. The passed value is compared to the current string, and if they are equal, the other value that was passed in is returned. If they are already different, the first value passed in is returned. Note that this method returns the new value but does not change the current string.
// alternate sort directions
sort = sort.toggle('ASC', 'DESC');
// instead of conditional logic:
sort = (sort == 'ASC' ? 'DESC' : 'ASC');
Defined in: aloha.js.
- Parameters:
- String value
- The value to compare to the current string
- String other
- The new value to use if the string already equals the first value passed in
- Returns:
- String The new value
Documentation generated by JsDoc Toolkit 2.4.0 on Wed Nov 30 2011 13:33:45 GMT+0100 (CET)