do is often incredible, and some functions can even be equivalent to the desktop program.
Now we can start with a javascript development framework prototype_1.3.1 (prototype. I would like to introduce the advanced javascript applications first, but I am afraid that the level is not enough and that it is not organized. Therefore, combined with prototype, I will mention js syntax usage by the way.
The follo
We have used prototype property simulation class and inheritance implementation in Chapter 1. The prototype attribute is essentially a JavaScript Object. Each function has a default prototype attribute.
If this function is used to create a custom object, we call it a constructor. For example, the following simple scenario:
// Constructor
Function Person (name ){
This. Name = name;
}
// Define t
Web page development, in many cases we need to manipulate the same class name elements, that is, class the same element. Yesterday to participate in the written exam, there is a related topic did not answer:
JavaScript Gets the node with class test in the page
Then collected a number of relevant data, in this article
ArticleDirectory
Introduction
1. Using a function
1.1. methods defined internally
1.2. Methods added to the prototype
2. Using Object literals
3. Singleton using a function
Summary
3 ways to define a javascript classintroduction
Javascript is a very flexible object-oriented language when it comes to syntax. in this article you can find three ways of defining and instantiating
1. Preface some people think JavaScript is a process-oriented language. Because basically all functions are written and called. ==> This idea is incorrect. The founder of JS is Brendan Eich. When JavaScript was founded, Java and object-oriented design had become popular. In May 1995, Netscape made a decision. In the future, the Web Page scripting language must "look similar to Java", but it is simpler than
Usually in the development process, accumulated a lot of experience and skills are applied to the project, and the next time you use it began to turn around. Sometimes also want to build a class library or toolkit to accumulate their own experience skills, and no special time to build a variety of environments, such as rollup or webpack such as packaging tools, ES6 transcoding tools Babel, Eslint, jest test tools and so on.Here is deliberately done a
definition, put the method outside using prototype to define. Solves the problem of the third method.
This method should actually be very friendly, but compared to Java syntax, there should be some disharmony, feel more messy, for C + +, we have less trouble feeling, but the development of C + + developers generally rarely involved in JavaScript, And for the developers of the Java EE, this approach is always somewhat awkward. The total feeling is not
Turn from: http://www.rainleaves.com/html/1684.html
A JavaScript static class is simply a class that does not have to be created by new, and can be used directly, like the built-in global class of JavaScript, such as math and object.
It's classname, not class.
Note that JavaScript uses classname to access the class attribute because class is a reserved keyword, because in the future JavaScript might begin to support classes like Java.
When we discussed the style attribute, we had a problem with tricky
The example in this article describes a method for JavaScript implementations like GetClass () in Java to get object class names. Share to everyone for your reference. Specifically as follows:
There is no function in JavaScript to return a particular type name
such as an object Console.log (obj);Get is [object Htmltablecellelement] If you want a function to be
1, Backbonejs: The JavaScript code to do MVC management, so as not to produce glue (glue) code, is on the basis of underscore to expand. Learning methods: Do an example to deepen your study.Need to understand Model,collection,views's respective responsibilities, collection is primarily the properties of the model's collection.2. Requirejs: Make asynchronous call to JavaScript code, the code of call should b
Class is one of the core concepts of object-oriented programming. A class represents the abstraction of a category of things with similar attributes. Starting with this article, we will formally enter the object-oriented part of JavaScript. The first thing to note is that there is no "class" keyword in
.
12
lt; Link href= "Default.css" rel= "stylesheet" Span class= "crayon-h" > type= "text/css" /gt lt; Script Type="text/javascript" src="Showhide.js"GT; lt; /scriptGT;
Forget to add your CSS and Javascript files to the XCode project (if is using external files).Some additional actions have the to is taken
= "createdom ()";Var title = "hello ";$ (Obj). append ("" + title + "");}
Don't tell me that you have never seen the above Code. To be honest, the above Code is indeed fast and simple to call. If the first two functions are not enough to trigger your indignation, so the third function should make you feel a little eager to greet the creator of the Code. Yes, the third function directly triggers my decision to use object-oriented.
In fact, I can transform the third function into the following.
In daily website development and web application development, we often need to effectively call functions related to date and time formats for Javascript processing, javascript contains some of the most basic built-in processing methods. Of course, if you have time, you can develop and compile the required methods by yourself. However, it is certainly a better way to effectively use the
When using some Javascript frameworks, you may see similar codeCopy codeThe Code is as follows:Var MyClass = new Class ({Initialize: function (param ,...){This. param = param;...},Func1: function (...){...}});Var myObj = new MyClass (param );MyObj. func1 (...);This is a typical object-oriented class mechanism application, which is clearer and more natural than th
Enrich your JavaScript library each good developer will form its own class library, and as a Java developer, we will also write a bunch of tools to simplify our development efforts. But as a full-station siege Lion, not just understand the formation of Java class Library, JavaScript
();
}
}
Man.prototype = new Person ();//prototype inheritance
Man.prototype.m2 = function () {
Object.getprototypeof (This). METHOD2 ();
}
var mans = new Man ();
MAN.M1 ();
MAN.M2 ();
The M1 method hanging on this in the subclass man calls the method1 on this in the parent class person, and the M2 method on the prototype calls prototype on the parent class METHOD2.
As
Class Definition and Inheritance of JavaScript
// Create the object var obj = {property: "this is property", method: function () {return "I'm a method ";}, // toString will be called when the Object is converted into a string, which can be used as the description of the Object toString: function () {return "I'm a Object ";}} // In the JavaScript specification, an
The example in this article describes the class dictionary insert or Update method for JavaScript implementations. Share to everyone for your reference. Specifically as follows:
The code expresses the class dictionary inserts or updates the related thought, the interested friend mainly understands the code meaning to be OK, does not need to delve into
T
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.