"Everything is Object" knows this in object-oriented programming languages, but it's a feeling for me, sensed it's hard to say. Because I am on JavaScript and weak, so look at the ASP.net Ajax class library at the same time also turned out ECMAScript by the way learn. All classes in. NET inherit from object, as well as in JS, so that if an object is extended, all descendants of the object class must have ancestry.
Now that I'm learning JavaScript, I'm going to mention it here. His original data type, in JS, there are 5 original data types (Undefined, Null, Boolean, Number, String), you can use the typeof to determine the variables and values of the data type
1. Undefined: When a variable is declared but not initialized, or the function does not explicitly return a value, the variable or function is the Undefined type and is an attribute of the null type.
2. Null: When the value of an object does not exist, the object returns NULL.
3. Boolean: A look to know that a man and a woman true/false, it is worth noting that 0 is not equal to false, but can be converted to false.
4. Number: You can define 32-bit integer data or 64-bit floating-point data. Some information on the web knows that floating-point numbers are stored in string type before they are computed (not known to be true). When floating-point type data is large or very small (you can move six bits back and forth), you will use the E notation to represent floating-point data, which can store up to 17 bits of data. In addition, the Isfinite () method can determine whether a numerical value is finite, and the isNaN () method can determine a non-numeric type of data. Other types can be converted to numeric types by parseint () and parsefloat (), and Nan (not a number) is returned if the conversion is unsuccessful.
5. String: This is the only original type with no size limit, and other types can be converted to string types through ToString (), and it is worth mentioning that the number converted to string type can be added to 2.8.16 as a parameter output binary, octal, and hexadecimal strings.
Let's take a look at the object type, with the Var obj=new object (), which can be used to declare an object. As with object in. NET, it is the base class for all classes.
It has two properties: constructor (equivalent to. NET, suggests an object function reference, and for the object class, the reference points to the local object () method. A reference value of the prototype object in the prototype object that reflects the properties and methods of prototype extensions in each object, and also uses this attribute class to extend and reflect classes in asp.net ajax.
hasOwnProperty-Determines whether the property attribute exists in the object, and the properties data type is string;isprototypeof (object)-Determines whether an object is another object's Prototype;propertyisenumerable-Determines whether the given property can be enumerated using a for statement; ToString ()-Returns the original type of the object string;valueof ()-Returns the appropriate original value of the object , for most classes, the returned value is the same as ToString (). These are the methods of the original object objects, which are similarly inherited in other classes.
In asp.net Ajax, Microsoft expanded the original object object to two methods in order to extend the entire class library to developers who are better suited to. NET:
Object.__typename= "Object";
Object.gettype=function (b) {
var a=b.constructor;
if (!a| | typeof a!== "function" | |! a.__typename| | a.__typename=== "Object") return object;
Return a
};
Object.gettypename=function (a) {
Return Object.GetType (a). GetName ()
};
From the above we can see that the Object.GetType (type) static method can get the object of a class, and object.gettypename (type) Gets the name of the class by calling [Prototype]type.getname () ( Include namespaces). There's nothing to say, but here's a look at the test:
<asp:scriptmanager id= "ScriptManager1" runat= "Server"/>
<div>
<script language= "JavaScript" >
Type.registerNamespace ("Nexplus");
Define a class;
Nexplus.objecttest=function (name) {
This._name=name;
}
Nexplus.objecttest.prototype.getname=function () {
return (This._name = = undefined)? Null:this._name;
}
Nexplus.objecttest.prototype.setname=function (name) {
This._name=name;
}
Register class;
NExplus.ObjectTest.registerClass ("Nexplus.objecttest");
Nexplus.testobject=function () {
var a=new nexplus.objecttest ("Test is success?");
document.write (A.getname ());
document.write ("<br/>");
A.setname ("success!");
document.write (A.getname ());
document.write ("<br/>");
document.write (Object.gettypename (a) + "<br/>")
}
Run
Nexplus.testobject ();
</script>
</div>
Run Result:
Test is success?
success!
Nexplus.objecttest
This is relatively simple, Microsoft just for and. NET Framework closer to the extended object class, I think these two should be rarely used in the development process, the above test by the way to test property J. I'd like to know if there's a good Samaritan. ECMAScript the standard documents, look at the real English class; By the way, I enclose a bundle of two operators: | | : From the first, encounter a meaningful return, otherwise return the last expression (not necessarily a Boolean); &&: From the first, encounter meaningless (0,null,undefined, "", False,nan) of the return, Otherwise, the last expression (not necessarily a Boolean value) is returned. Http://www.cnblogs.com/xdotnet/archive/2006/12/25/nexplus_aspnet_ajax_object_extend.html