AJAX and JavaScript scripting language

Source: Internet
Author: User
Tags hasownproperty

JavaScript also plays a major role. Next I will introduce the advanced knowledge of JavaScript.


 

Use the. Operator

 

 

Var count = 0; varaddCount = function () {count ++ ;};}; functionooTest () {// generate an object based on class name reflection, only know Book, the parameter "wang" var book = reflect ("Book", ["wang"]); alert (book. getName (); // determines whether an object has a certain attribute. // The hasOwnProperty method can only determine the attributes directly defined on the object, var bool = book cannot be directly determined for inherited attributes. hasOwnProperty ("name"); alert (bool); // an alternative method is required for the inherited attributes such as getName to be judged as var bool2 = book. hasProperty ("getName"); alert (bool2); // traverses all attributes on the book object for (varpro Name in book) {alert (book [proName]) ;}// if we need to obtain an object, all attribute values are not the function attribute varproArray = []; for (varproName in book) {vartemp = book [proName]; if (typeof temp! = "Function") {proArray. push (proName) ;}} alert (proArray );

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.