JS Learning basic Sharing Summary

Source: Internet
Author: User

1, Javascirpt contains three aspects:

ECMAJAVASCIRPT: Providing the core language

DOM: Provides a way to access and manipulate page content

BOM: Provides interfaces and methods for interacting with the browser

2. JAVASCIRPT has 6 data types: string, Boolean,number,null,undefined,object, etc.

TypeOf ("23"); // stringtypeOf (23); // number TypeOf (true); // booleantypeOf (null); // objecttypeOf (undefined); // undefinedtypeOf (function() {}); // function

3. There are 3 kinds of loop statements: While statement, Do-while statement, for statement

4. Cast Type: Number (""), parseint (""), Parsefloat ("), Boolean (); It's worth noting that

Number (null);//0number (undefined);//nannumber ({});//nanboolean (1);//trueboolean (0;//falseboolean ("");// Falseboolean (null);//falseboolean (undefined);//falseboolean ("false");//true
Number ("123abc");//nan
parseint ("123abc");//123

5. How to determine whether a property exists in an object

varP1={name: "Lily", age:23}p1.name;//"Lily"P1.ismale://undefined;//This gives you access to the object's properties, which can not be judged by undefined, so take a look at the following codevarP1={name: "Lily", age:undefined} p1.age;//undefined;//the same thing happens when undefined can't use undefined to determine if an object exists.the P1.hasownproperty can only be used in two different ways ("Name");//true"Name"inchP1;//true

6. Any elements that traverse an object

var p1={name: "Lily", age:23}object.keys (p1); // ["Name", "Age"] Object.getownpropertynames (p1); ["Name", "Age"] for (var prop in   p1) {console.log (P1[prop]);} // lily,23

JS Learning basic Sharing Summary

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.