Js__class into the pit Chrome tests class parent-child inheritance relationships

Source: Internet
Author: User

Emmm ... See the parent-child relationship directly by testing:

class a{Constructor () {//does not have to         This. Name= "Class_a"; //Console.log (This)//a {name: "Class_a"} (another line) B {name: "Class_a"}//the parent class subclasses performed a} static Staticcallnamea () {return"Name_a"; } Callnamea () {return"Name_a"; } static cover () {return"Cover_a"}}class B extends a{constructor () {//subclasses can not addSuper ();//subclasses must have    //Console.log (This)//b {name: "Class_a"}//will print directly} static Staticcallnameb () {return"Nameb"; } callnameb () {return"Name_b"; } static cover () {return"Cover_b"    }}
Console.log (A.name,b.name)//A B//(class name)Console.log (A.staticcallnamea (), B.staticcallnamea ())//Static subclass Inherits parent classConsole.log (A.cover (), B.cover ())//cover_a cover_b//read-ahead subclass re-read parent classConsole.log (A.STATICCALLNAMEB)//Undefined//parent class does not have subclass-specific functionsConsole.log (A.CALLNAMEA,B.CALLNAMEA)//undefined undefined//non-static method class cannot be called directlyLet a=NewA (), b=NewB//add no parentheses to the same effectConsole.log (A.name);//class_aConsole.log (A.name,b.name)//class_a class_aConsole.log (A.callnamea (), A.callnameb,b.callnameb (), B.callnamea ())//name_a undefined name_b name_a//Description inheritance relationship Ibid .

Welcome to the Great God of guidance ...

Js__class into the pit Chrome tests class parent-child inheritance relationships

Related Article

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.