zhiqingstudy

Be a young person with knowledge and content

Constructor is a special function, mainly used to initialize objects

Usage scenario: The regular {...} syntax allows you to create an object. Constructor can quickly create multiple similar objects

Constructors are technically regular functions

But there are two agreements

1. Their names begin with capital letters

2. They can only be executed by the "new" operator

        function Pig(name,age,gender){
            this.name=name
            this.age=age
            this.gender=gender
        }
        const Peppe=new Pig('佩奇','16','男')
        const George=new Pig('乔治','18','男')
        const Mum=new Pig('猪妈妈','43','女')
        const Dad=new Pig('猪爸爸','45','男')
comment
head sculpture
Code:
Related

The art of interpersonal communication and communication

A code of conduct that regulates and regulates interpersonal relationships

The importance of interpersonal relationships




Unless otherwise specified, all content on this website is original. If the reprinted content infringes on your rights, please contact the administrator to delete it
Contact Email:2380712278@qq.com

Filing number:皖ICP备19012824号