Javascript is a very powerful object-based language. However, the support for object-oriented (Object Oriented) still has some shortcomings. At the same time, the built-in JavaScript class libraries are also relatively simple, it even lacks all the common functions. ASP. NET Atlas extends JavaScript at runtime, greatly enhances its object-oriented support capability, and extends some common operations for development.
I have referenced the Atlas. js file and concluded that Atlas has the following extensions for javascript. Some omissions or errors may occur. Please forgive me and correct me.
String object extension
1. String string. ltrim ()
Removes all spaces starting with the original string and returns a New String object.
2. String string. rtrim ()
Remove all spaces at the end of the original string and return a New String object.
3. String string. Trim ()
Removes all spaces starting and ending with the original string and returns a New String object.
4. boolean string. endswidth (strend)
Whether the string ends with the input string.
5. boolean string. startswith (strstart)
Whether the string starts with the input string.
6. String string. Format (args1, args2 ,.)
Similar to string. Format () in C #, {n} in the operated string is replaced with the corresponding nth parameter, and a new String object is returned.
7. String string. removespaces ()
Remove all spaces from the original string and return a New String object.
8. String string. removeextraspaces ()
Replace consecutive spaces in the original string with a single space (including carriage return) and return a New String object.
9. String string. removespacedelimitedstring (STR)
Removes the specified word (separated by spaces) from the original string and returns a New String object. This method can be used to delete a class name that contains multiple class names DOM elements.
Array object extension
1. Void array. Queue (objvalue) and void array. Add (objvalue)
Insert the specified objvalue to the end of the array.
2. Void array. addrange (rangearray)
Adds the specified rangearray to the end of the array.
3. boolean array. Contains (objvalue) and Boolean array. exists (objvalue)
Returns a Boolean value indicating whether the array contains the objvalue project.
4. array. Clone ()
Returns a shortest copy of the array.
5. Void array. insert (index, objvalue)
Insert the specified objvalue to the index position of the array.
6. Object array. dequeue ()
Remove and return the first entry in the array.
7. Object array. removeat (INDEX)
Remove and return the specified index entries in the array.
8. boolean array. Remove (objvalue)
Removes the specified objvalue entry from the array. The returned Boolean value indicates whether the entry exists and is successfully removed.
9. array. parse (string)
Parses the input array in string format into an array.
10. Void array. Clear ()
Clear all entries in the array.
11. Integer array. get_length ()
Returns the number of entries in the array, which is equivalent to array. length.
12. Object array. getitem (INDEX)
Returns the entry of the specified index in the array.
Date object extension
1. String date. toformattedstring (stringformat)
Format and output the date object according to the input stringformat (the format string is too large ...... If you are too lazy to write the code, you can directly check lines 748-871 in Atlas. JS ).
Number object extension
1. Number number. parse (string)
Try to parse the input stirng as number.
2. String number. toformattedstring (stringformat)
Format and output the number object according to the input stringformat (the format string is too large ...... If you are too lazy to write it, you need to directly read the 935-1024 lines in Atlas. JS ).
SYS. stringbuilder class
Similar to stringbuilder in C:
VaR sb = new SYS. stringbuilder ();
SB. append ("<div> ");
SB. appendline ("a line of text ");
SB. append ("</div> ");
Somedomelem. innerhtml = sb. tostring ();
Object-oriented support
Define a base class that can be inherited
Baseclass = function ()
{
// Object
}
Baseclass. registerclass ("baseclass ");
Inheritance class
Derivedclass = function ()
{
// Call base Constructors
// The 2nd argument is an array you can use to pass arguments
Derivedclass. intializebase (this, arguments );
}
Derivedclass. registerclass ("derivedclass", "baseclass ");
Multi-Inheritance
Multipleinherit = function ()
{
Multipleinherit. intializebase (this, arguments); // Bootstrap
// Object
}
Multipleinherit. registerclass ("multipleinherit", ["baseclass", "derivedclass"]);
Define override Methods
Baseclass = function ()
{
// Object
This. initialize = function ()
{}
Baseclass. registerbasemethod (this, "initialize ");
}
Baseclass. registerclass ("baseclass ");
Call the base class override method
Derivedclass = function ()
{
Derivedclass. initializebase (this, arguments); // Bootstrap
This. initialize = function ()
{
Derivedclass. getbasemethod (this, "baseclass", "initialize"). Call (this );
// To pass arguments to base class:
//. Call (this, args1, args2, args3)
}
}
Derivedclass. registerclass ("derivedclass", ["Atlas. bindings. Base", "baseclass"]);
Namespace
Registernamespace ("Web. utility ");
// Implement web Utility
Registernamespace ("Web. Performance ");
// Implement performance
Define the enum type
VaR theenum = type. createenum ("name1", "name2 ");
For (VAR stritems in theenum. getvalues ())
{}
Define the Flag type
VaR theflags = type. createflags ("name1", value1, "name2", value2 ,);