JavaScript Object-oriented Programming Guide notes

Source: Internet
Author: User

Variable declaration:

var v1,v2 = ' Hello ', v3=42;

The data types in JavaScript are divided into two parts: primitive types (numbers, strings, Booleans, Undefined,null), and object types.


-View variable type operator typeof variable or value


-When a number begins with 0, it indicates that it is an octal number. 0377 represents the decimal number 255; The 0x prefix is the hexadecimal number

-Infinity Any number beyond the JavaScript, divided by 0 results is also Infinity

-When strings are used for arithmetic operations, they are used as numeric types. string-and number will be multiplied by 1. or use the parseint () function

Other types-strings are added to the empty string.


-Special word acts when you want to use quotation marks as the contents of a string, \ \ \ \

\u are treated as Unicode codes after the

-Array

var a = [];

When you delete an array element, the array length is not affected, but the position is left blank (undefined).


-check if the variable exists if (typeof somevar! = "undefined")


-Function parameters for passing more parameters, the extra part will only be silently ignored.


-Encoding and de-coding of URIs

encodeURI () result "http://www.packtpub.com/src%20ipt.php?q=this%20" decodeURI

encodeURIComponent () result "http%3a%2f%2fwww.packtpub.com ..." decodeuricomponent


-Variable Scope

A function field always takes precedence over a global domain, and a local variable overrides all global variables that have the same name as it.

When the execution process enters a new function, all variables declared within the function are moved to the beginning of the function.

var a = 123;

function f () {

var a;//same as:var a = undefined

alert (a);//undefined

A = 1;

alert (a);//1

}

The function in JavaScript is also a kind of data, 1. They contain code 2. They are executable (callable)


JavaScript Object-oriented Programming Guide 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.