The OOP language gives us the ability to customize objects and variable types.
Object Oriented Programming
JavaScript is an object-oriented programming language (OOP). The OOP language gives us the ability to define our own objects and variable
There are several ways to implement inheritance in JavaScript, and here are two common types.
One, call inheritance, first look at the code:
First define a "people" class
Copy Code code as follows:
Human
Person=function () {
The last two sections talk about JavaScript object-oriented namespaces and JavaScript-oriented JavaScript classes, so you can look at the above and continue to look down.
In fact, it is very simple, less talk, read the following code and comments
In small projects for JavaScript use, just write a few function on the line. But in large projects, especially in the development of the pursuit of a good user experience of the site, such as SNS, will use a lot of javascrpt, sometimes the workload
After looking at a lot of data, I summarized the following three rules, these three rules, have been able to solve all the problems I have encountered at present.
Rule 0: The function itself is a special type, most of the time, it can be considered
The first type is the previously mentioned private type, which is characterized by a complete lack of access to the outside world to access them, only through specific getter and setter.
The second type is a dynamic public type, characterized by
Encapsulation : The pattern of creating objects in JavaScript, which is considered by the individual to be a true encapsulation in the case of a closure, so let's start with a brief introduction to the closure and look at the following example:
/*
All options */
function Sb002selectall ()
{
var table = document.getElementById ("Ctl00_maincontent_grvdevelopkit");
for (Var i=1;i{
var input = table.rows[i].cells[0].getelementsbytagname ("input") [0];
input.checked =!this.checked;
}
}
/*
All
JS Code
//1. Determine if there is a value= "Paravalue" Item in the Select option
function Jsselectisexititem (Objselect, Objitemvalue) {
var isexit = false;
for (var i = 0; i if (Objselect.options[i].value = = Objitemvalue) {
Isexit = true;
Break
Thank you for the regular of the waves, the original paste see:
Http://www.iecn.net/bbs/view/106503.html
Because you want to make a template replacement thing, inside the variable to use ${myname} This format naming method. There are two
Iterative methods
Iterative methods are particularly important in JavaScript, and in many cases there are actual requirements, JavaScript provides 5 iterative methods for us to operate, respectively:
Every () each item in the array uses the given
The IMG element allows us to embed images in HTML documents.
To embed an image you need to use the SRC and ALT attributes, as follows:
"
Display effect:
1 embedding an image in a hyperlink
A common use of an IMG element is to
This article provides a simple JS introductory tutorial, this is a JS array definition and array length example tutorial, if you are learning the JS array, we show you here how to define the array and increase the array and array length calculation
Bubble sort: Arranges the elements in an array in order from big to small or from small to large.
var array=[9,8,7,6,5,4,3,2,1];
The first round comparison: 8,7,6,5,4,3,2,1,9 exchanged 8 times i=0 j=array.length-1-i
Second round
1, operator
An operator is a sequence of symbols that completes an operation, and it has seven classes:
Assignment operators (=,+=,-=,*=,/=,%=,>=,|=,&=), arithmetic operators (+,-, *,/,++,--,%), Comparison operators (>,=,==,== =,!=,!==), logical
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