JS Basic _this

Source: Internet
Author: User

1 <!DOCTYPE HTML>2 <HTML>3     <Head>4         <MetaCharSet= "UTF-8">5         <title></title>6         <Scripttype= "Text/javascript">7         8             /*9 * The parser passes an implicit argument to the inside of the function each time the function is called.Ten * This implied argument is that This,this is pointing to an object, One * This object we call the context object for function execution A              *      - * Depending on how the function is called, this will point to a different object - * 1. When called as a function, this is always the window the * 2. When called in the form of a method, this is the object that invokes the method -              */ -              -              +             functionFun () { - Console.log ( This);//[Object Window] +             } A               at Fun (); -              -             //----------------------------------------------------------------------------------- -              -             functionfun2 () { - Console.log ( This); in Console.log ( This. Name);//Monkey King -             } to              +              -             //Create an Object the             varobj= { * Name:"Monkey King", $ sayname:fun2Panax Notoginseng             }; -              the Console.log (Obj.sayname==fun2);//true +              A             //the same function is called, but the result is different, depending on how the function is called, this will point to a different object the obj.sayname ();//[Object Object] +              - fun2 ();//[Object Window] $              $               -              -         </Script> the     </Head> -     <Body>Wuyi     </Body> the </HTML>

JS Basic _this

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.