JavaScript Learning Notes

Source: Internet
Author: User

Standard: Structure standard (XHTML), Performance Standard (CSS), Action Standard (JS)
CSS Four styles: inline style > Inline style > Link style > Import style.
Margin: upper right down left
margin:20px 0; margin:20px 0 20px 0; is equivalent

Three components of javascript:
ECMAScript (language function, grammar, structure, etc.)
DOM: Document Object Model (map a Web page to a multilayer node model)
BOM: Browser object Model (interoperability of browsers)
XHTML and HTML:
XHTML is a further specification of HTML in accordance with the syntax of XML, typically using CDATA for HTML and XHTML compatibility

<script> Place the difference between Put in head, load <script> script before loading page, extend the loading time of the interface
In the body, usually at </body> before the end of the page to improve the efficiency of loading.
Browser processing <script> tags are sequential, if you need to change the loading order, take advantage of the defer and Asyn properties provided by <script>

Defer: Used for external files, which means immediate download, but can delay load execution, usually only one defer attribute in a file
Asyn: Asynchronous execution, no guarantee of file load order

ECMAScript, as a standard specification for JavaScript implementations, describes the syntax, operators, data types, built-in functions, etc. that are included in the implementation process.
ECMA-262 is the version number of ECMAScript

ECMAScript Case Sensitive

About variables:
The definition of a variable is usually performed using the var operator, which is not recommended if you omit the var operator in the method as a global variable
Variable to have its own scope
Only one operation is allowed for variables that have been declared--typeof ()

Five basic types of ECMAScript: Undefined, Null, Boolean, String, number
A complex type of ECMAScript: Object

A null type has a unique value: null
A null value represents an empty object pointer, and you can assign a change amount to NULL if you need to create an object without rushing to assign a value.
Undefined is derived from null, so Undefined==null is established

The Boolean type has only two values true/false (must be lowercase)

Number types include floating-point types and integer types (two or eight, 16 or 16), and octal and hexadecimal are converted to decimal when numeric operations are performed
Numeric conversion Method: Number ()/parseint ()
Number ("Hello")//nan
Number ("")//0
Numer (True)//1
Number ("000011")//11
*******************************
parseint ("124red")//124
parseint ("")//nan
parseint ("0xA")//10
parseint ("070")//56
parseint ("70")//70
parseint (param, radix)//cardinality is used to determine how many binary conversions
*********************************
Parsefloat (), like the parseint () rule, parses the parameter from the first position until the argument ends without a number, but it has only one parameter and no cardinality

Nan:not A number is not a numeric type, NaN is not equal to any value, including itself
*************************************
String type conversion: toString ()
Each string has a ToString () method, except for undefined and null
to specify cardinality you can add a parameter ToString (2/8/10/16) to the ToString method
To convert the undefined and null values to a string type (that is, to output "undefined" and "null" characters) you can use the string () function, which can convert any type
*****************
Object Type
var o = new Object ();
Constructor:object ()//constructor
Hasowenproperty (PropertyName)//Check whether the property is in the current object instance
isprotypeof (object)// Check if the incoming object is a prototype (instance) of the incoming object?
propertyIsEnumerable (PropertyName)//checks whether a given property can use the For-in statement to enumerate
toLocaleString ()//The string representation of the returned object
ToString ()
ValueOf ()
————————————————————————————————————————————————————————————
About comparison:
equality and inequality (= =,! =): Convert and compare first
(Boolean,number)//boolean convert to numeric type compare
(string,number)//string convert to numeric type and then compare
(object,number)//Use valueof () Convert object to base type before comparing
(Object,object)//Two objects compare whether they point to the same object
Note: The comparison between Nan and undefined cannot be done with any conversions equal

Change a string to a value: use-number
Change a value to a string: Use the + sign
===:1, Comparison type 2, Comparison value
typeof (NULL): object//basic type and function detection, but cannot detect null
instanceof//custom objects and native objects, detecting failures between iframe and window
object.prototype.tostring//built-in objects and underlying types, with browser compatibility issues with NULL and undefiened

For-in:for (property in expression)

Named arguments that define a function are provided for convenience only and are not required, and can be passed without arguments or by the number of specified arguments when the function is called.
function Sayhi (name,message) {
Statement
}
Sayhi () {
Alert (aregument[0]);//aregument[0] equivalent to name
Alert (aregument[1]);//aregument[1] equivalent to a message
Aregument[0]= "Lisa"; only value is passed in//ecmascript, this is simply a value modification to the passed-in parameter and does not modify the name of the original function definition
}

ECMAScript only covers, no overloads
————————————————————————————————————————————

JavaScript Learning Notes

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.