In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "how to understand ECMAScript basic classes and Asp.net Ajax classes". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to understand ECMAScript basic classes and Asp.net Ajax classes".
"Everything is Object" is a phrase that everyone knows in an object-oriented programming language, but to me it's a feeling that it's hard to put into words. As I am weak on JavaScript and, I read the Asp.net Ajax class library and find out ECMAScript to learn by the way. All classes in .NET inherit from Object, and it is also said in JS that all classes inherit Object, so if Object is extended, then all descendants of Object classes must have ancestral blood.
Since you start to learn JavaScript, by the way, mention its primitive data types here. There are five primitive data types in JS (Undefined, Null, Boolean, Number, String). You can use typeof to determine the data types of variables and values.
1. Undefined: when a variable is declared but not initialized, or when a function does not explicitly return a value, the variable or function is a Undefined type, which is a property of the Null type.
2. Null: when the value of an object does not exist, the object returns null.
3. Boolean: you can see at a glance that a man and a woman true/false, it is worth noting that 0 is not equal to false, but it can be converted into false.
4. Number: you can define 32-bit integer data or 64-bit floating point data. According to some data on the Internet, floating-point numbers are stored as String before they are counted (I don't know if it's true or false). When floating-point type data is large or small (six bits can be moved back and forth), E notation is used to represent floating-point data, which can store up to 17 bits. In addition, the isFinite () method can determine whether a value is finite, and the isNaN () method can determine whether a data is of a non-numeric type. You can convert other types to numeric types through parseInt () and parseFloat (), and return NaN (Not a Number) if the conversion is unsuccessful.
5. String: this is the only primitive type with no size limit, and other types can be converted to String type by toString (). It is worth mentioning that numbers can be converted into String type by adding 2.8.16 as a parameter to output binary, octal and hexadecimal strings.
Let's take a look at the Object type, which can declare an object through var obj=new Object ();. Like Object in. Net, it is the base class for all classes.
It has two properties: constructor (the equivalent of a constructor in .NET) suggests an object function reference, which in the case of the Object class points to the local Object () method. A reference value of the prototype object in the Prototype object, through which the properties and methods of the prototype extension in each object can be reflected. In Asp.net Ajax, this property class is also used to extend and reflect the class.
HasOwnProperty (property)-determines whether the property attribute exists in the object, the property data type is string;isPrototypeOf (object)-determines whether one object is prototype;propertyIsEnumerable (property) of another object-determines whether the given attribute can be enumerated using the for statement; toString ()-returns the original type of the object string;valueOf ()-returns the appropriate original value of the object, and for most classes, the returned value is the same as toString (). These are the methods of the original Object object, which are also inherited in other classes.
In order to make the entire class library more suitable for .NET developers in Asp.NET Ajax, Microsoft extended two methods in the original Object object:
Object.__typeName= "Object"
Object.getType=function (b) {
Var a=b.constructor
If (! a | | typeof axioms = "function" |! a.__typeName | | a.roomroomtypename names = "Object") return Object
Return a
}
Object.getTypeName=function (a) {
Return Object.getType (a) getName ()
}
As we can see from above, the static method Object.getType (type) can get the object of a class, while Object.getTypeName (type) gets the name of the class (including the namespace) by calling [prototype] Type.getName (). There's nothing to say, so let's take a look at the test:
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?")
[xss_clean] (a.getName ())
[xss_clean] (")
A.setName ("Success!")
[xss_clean] (a.getName ())
[xss_clean] (")
[xss_clean] (Object.getTypeName (a) + "")
}
/ / run
NExplus.TestObject ()
Running result:
Test is success?
Success!
NExplus.ObjectTest
Thank you for your reading, the above is the content of "how to understand ECMAScript basic classes and Asp.net Ajax classes". After the study of this article, I believe you have a deeper understanding of how to understand ECMAScript basic classes and Asp.net Ajax classes, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.