ECMAScript base classes and asp.net AJAX extensions to class object

Source: Internet
Author: User
Tags constructor extend numeric object object

"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 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, other types can be converted to string type by 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()

};

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.