Class String
Package: | Global |
Class: | String |
Extends: | Object |
Defined In: | Ext.js |
These functions are available as static methods on the JavaScript String object.
Properties
-
Methods
-
Events
Public Properties
This class has no public properties.
Public Methods
|
escape( String string ) : String |
String |
<static> Escapes the passed string for ' and \ |
|
format( String string , String value1 , String value2 ) : String |
String |
<static> Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the token... |
|
leftPad( String string , Number size , [String char ] ) : String |
String |
<static> Pads the left side of a string with a specified character. This is especially useful
for normalizing ... |
|
toggle( String value , String other ) : String |
String |
Utility function that allows you to easily switch a string between two alternating values. The passed value
is compa... |
Public Events
This class has no public events.
Method Details
escape
public function escape( String string
)
<static> Escapes the passed string for ' and \
Parameters:
string
: StringThe string to escape
Returns:
This method is defined by String.
format
public function format( String string
, String value1
, String value2
)
<static> Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens. Each
token must be unique, and must increment in the format {0}, {1}, etc. Example usage:
var cls = 'my-class', text = 'Some text';
var s = String.format('{1}
', cls, text);
// s now contains the string: 'Some text
'
Parameters:
Returns:
String
The formatted string
This method is defined by String.
leftPad
public function leftPad( String string
, Number size
, [String char
] )
<static> Pads the left side of a string with a specified character. This is especially useful
for normalizing number and date strings. Example usage:
var s = String.leftPad('123', 5, '0');
// s now contains the string: '00123'
This method is defined by String.
toggle
public function toggle( String value
, String other
)
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');
This method is defined by String.