Course Review of network programming

Source: Internet
Author: User

JS behavior: The process of an action (action) taken in response to an event. Consists of two parts: Action and event.

JS data type
1. Basic data type: Number, Boolean, string, null, undefined
2. Reference data type: (1) Host object: BOM, DOM (2) built-in object: Global, Math (3) Native object: String Boolean Date Array Object number RegExp

Array
Create:
1, var array=new array (5); Array[1]=a;array[2]=2, .....
2, var array=new array (1,2,3,a);
3. var array=[1,3,a,h]
Add a column to the array: Array.push ("Xiaoming")
Delete array column: Array.pop ("Xiao Ming");
Connect the elements in the array: Array.join ("---")
Merge two arrays into a new array: Array1.concat (array2)

Conversion of data types
Automatic conversion: Any data and string addition is a string, subtract converts the string to an integer, or Nan if it cannot be converted
Cast: (1) Convert to a string:
The toString () function, the conversion of number type has default mode and base mode for null and undefined value casts will error. Num.tostring (); num.tostring (4) (binary conversion)
String () can convert any value to a string, and the only difference between this cast and ToString () is that the null and undefined values can be cast without error.

(2) Convert a string to a number:
parseint () function: Find the number, if the number is directly returned, encountered a non-numeric cutoff, if the first non-numeric return Nan, there is a base mode parseint (10,count (6));

Parsefloat () function: View each character starting at position 0 until the first non-valid character is found, and then turn the string before the character
Change to an integer. However, for this method, the first decimal point that appears is a valid character. If there are two decimal points, the second decimal point will be considered invalid. Parsefloat () will take this
The character before the decimal point is converted to a number. This means that the string "11.22.33" will be parsed into 11.22. Another difference between using the Parsefloat () method is that the string must be in decimal form
Represents a floating-point number instead of octal or hexadecimal. The method ignores the leading 0, so the octal number 0102 is parsed to 102. For hexadecimal number 0xA, the method returns NaN,
Because in floating-point numbers, X is not a valid character. (Note: After testing, the specific browser implementation returns 0, not NaN.) )

Number () function: it only converts the entire value, not the partial value. Remember, the parseint () and parsefloat () methods only convert strings before the first invalid character, so "1.2.3" is converted to "1" and "1.2" respectively. Coercion type conversion with number (), "1.2.3" returns Nan because the entire string value cannot be converted to numbers. If the string value can be fully converted, number () will determine whether to call the parseint () method or the Parsefloat () method. Number () is false in parentheses, return 0,true returns 1

(3) Convert to a Boolean value:
Boolean () Function: the Boolean () function returns True when the value to be converted is a string of at least one character, not a 0 number, or an object. If the value is an empty string, the number 0, undefined, or null, it returns FALSE.

Object-Oriented inheritance
1, Impersonation: Subclass name Instanceof Parent class name ==false
Subclass: This.inherit= Parent class function name, This.inherit (name)
Child class: Parent class name. Call (This,name)
Subclass: Parent class name. Apply (This,[name,age])
2. Prototype chain: Subclass name Instanceof Parent class name ==true
Outside subclass: Subclass Name Prototype=new Parent class name ();

JS selector: document.getElementById ();d ocument.getelementsbyclassname ();

Bfc:block formatting context, triggering elements in the BFC cabinet will not affect elements outside the cabinet

A reference to a CSS style:
Inline: <p style= "color:red;width:100px" ></p>
Internal:<style>.div{width:100px;height:100px}</style>
external: <link href= "CSS file path" type= "Text/css" rel= "stylesheet" >

A reference to the JS behavior:
Inline: <a href= "Javascript:alert (' win ')" ></a>
Internal:<script>...</script>
external: <script src= "file path" type= "Text/javascript" ></script>

JS Control CSS
Inline:. Style
Internal and external: Var od=document.stylesheets (Gets the number of internal and external styles) gets the specific style of the first: Firefox: od[1].cssrules ie:od[1].rules
Final style (read only): Firefox Document.defaultView.getComputedStyle (document.getElementById ("Div1"), "" ");
IE Document.currentstyle;

Binding and unblocking of JS events:
Tradition: Document.getelementbytagname ("P") [0].onclick=function () {}
Modern events: False bubbling, true capture
var Oo=document.getelementbyid ("Div1")
Function Show () {}
Firefox: Oo.addeventlistenner ("click", Show,false/true);
Oo.removeeventlistenner ("click", Show,false/true);
IE:oo.attachEvent ("onclick", show) (ie can only bubble, and the quotation mark must be a missing tangent function)
Oo.detachevent ("onclick", show)

Selector Priority:
inline > Internal > External
Id>class
Pseudo-Class and class precedence are the same, but when there are elements in front of the pseudo-class, their precedence is higher than the class
The lowest priority is *, the highest time! Important

Refresh page:
Window.reload;

Bom:
Timer: SetTimeOut (test,2000) wait two seconds to execute the test function
Interval execution: setinterval (test,2000) interval two seconds to execute test
Pop-up the dialog box to the user and wait for the user to close: Alert
The dialog box pops up and returns a Boolean value: Confirm
Pop-up input box: prompt (user input is String type)
. Close (): Close window
Window.screen.height/width/colordepth/navagitor

Hiding elements in CSS:
1. Use Display:none to hide all content
Display:none can let all the content in the page not display, such as code, text, links, pictures, div layer, is the recommended content hiding way.
2. Use Visibility:hidden to hide content
Visibility:hidden and Display:none can hide the content almost the same, but the only difference is that while it hides the content, the hidden content still occupies space, and the space where the content is hidden will appear blank in the page.
3, Overflow:hidden This way can hide the content outside the fixed area, it can effectively control the display area. It should be noted, however, that you need to define a width and height for it, otherwise it will not work.
4. opacity:0 Opacity Properties I believe we all know that the transparency of the element is expressed, and the transparency of the element is set to 0, and in our user's eyes, the element is hidden, which is a method of hiding the element.


Course Review of network programming

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.