Learning Path 1 recording notes in learning

Source: Internet
Author: User


Object-oriented design is based on three main principles: encapsulation, inheritance, and polymorphism.
Class can define objects

 

There is no "class" in Javascript. classes have been made invisible and integrated with objects.

The process of creating an object in the form of VaR anobject = new afunction () can be divided into three steps: the first step is to create a new object; step 2: Set the built-in prototype object of the object to the prototype object referenced by the constructor prototype. Step 3: Call the constructor as the this parameter to complete initialization such as member settings.

Function CAT (name)
{
This. Name = Name;
This. Talk = function () {alert (this. Name + "say meeow! ");}
}
Cat1 = new CAT (" ");
Cat1.talk ();
Three methods:

VaR woman = {};
Woman. face = "variable ";

Woman = {Face: function () {return: "array "}};

Woman. Face = function () {return "method "};


Innertext, innerhtml
Difference: innertext output text
Innerhtml outputs htmlCodeFor example, output. innerhtml = "output text here: <u>" Export frm.txt. Value + "</u> ";

 

 

PM
Get =========== post
Get is passed explicitly. It is displayed in the URL. What makes a mistake is: var url = "addbook. asp? Username = "+ escape (username );
// XMLHTTP. setRequestHeader ("Content-Type", "application/X-WWW-form-urlencoded ");

XMLHTTP. Open ("get", URL, true );
I thought about using post. That's not enough.

Yes
Document. getelecmentbyid
Document. getelecmentbyname
Instead
Document. getelecmentsbyid
Document. getelecmentsbyname
(Note that S is not added)

PM
JavaScript Object Notation (JSON) is a new buzzword that suddenly appears around the Ajax topic. JSON, simply put, is a method for defining objects in JavaScript. Let's take a look at an instance immediately and learn how simple it is.

 

 


Obj1.fun1. Apply (obj2, ["test"])
Pass the obj1 function to obj2 and the test parameter.

2. Inheritance

Javascript itself does not provide inheritance. How can we implement class inheritance? The most direct and big method is to copy the original method and add new members to it. However, this is really lagging behind, because when the original class changes, the new inherited class needs to be manually changed, which is prone to errors. However, the replication controlled by for in is less prone to errors.

Function test1 ()

{

For (P in test. Prototype)

{

Test1.prototype [p] = test. Prototype [p];

}

Test1.prototype. newmethod = function ()

{

Alert ("newfunction ");

}

}

You can use window. Screen. Height to get the screen size.
You can use document. Body. clientwidth to get the browser size.

<Input type = "button" value = "display" onclick = 'change ("div1", "user1 ");'
When passing parameters,
Quotation marks required

\ W: match any word character that contains underscores, equivalent to [A-Z A-Z 0-9 _]
\ W: match any non-word character, equivalent to [^ A-Z A-Z 0-9 _]

 

<H3> today is:
<%
Weekname = array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday ")
P year (date () & "year" & month (date () & "month" & Day (date ()) & "day" & weekname (weekday (date ()-1)
%>
</H3>

 

2-20 hexadecimal conversion :-----------------------
<Script language = "JavaScript">

VaR I = 999;
For (var j = 2; j <20; j ++ ){
Document. Write (J + "hexadecimal:" + I. tostring (j) + ";");
}
</SCRIPT>

When comparing a number with a character number, convert the character to a number first, and then compare 23 <"3" to return false.
Returns true if two character numbers are compared to the code size of the first digit "23" <"3"

 

The with statement specifies the default object for one or more statements.

Usage: With (<Object>) <Statement>;

The with statement is usually used to shorten the amount of code that must be written in a specific situation. In the following example, pay attention to the reuse of Math:

X = math. Cos (3 * Math. Pi) + math. Sin (math. ln10 );
Y = math. Tan (14 * Math. E );

When the with statement is used, the Code becomes shorter and easier to read:

With (math ){
X = cos (3 * PI) + sin (ln10 );
Y = tan (14 * E );
}

 

In HTML, The innerhtml of the table object is a read-only attribute. Refer to the Microsoft documentation: (therefore, innerhtml cannot be used in table)

The property is read/write for all objects tables t the following, for which it is read-only: Col, colgroup, frameset, HTML, style, table, tbody, tfoot, thead, title, TR. the property has no default value.

The shortest time display method is as follows:

<Div id = "A"> <SCRIPT> setinterval (". innerhtml = new date (). tolocalestring () + 'Week' + 'may 15, 1234 five or six '. charat (new date (). getday () ", 500) </SCRIPT> </div>
// New date (). getday () returns the day of the week.

Three types of rounding: Ceil (), floor (), round ()
Ceil () rounded up, floor () rounded down, round () rounded up

3.3 built-in objects

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.