es6-test.js 858 Bytes
class Animal {
    constructor() {
        this.type = 'animal';
    }
    says(say = 'hi') {
        setTimeout(() => {
            console.log(`${this.type} says ${say}`);
        }, 1000);
    }
}

class Cat extends Animal {
    constructor() {
        super();
        this.type = 'cat';
    }
    setInfo(info) {
        let {name, age, color} = info;

        name && (this.name = name);
        age && (this.age = age);
        color && (this.color = color);
    }
    infos() {
        console.log(this);
    }
}

const timeout = (ms) => {
    return new Promise((resolve) => {
        setTimeout(resolve, ms);
    });
};

function* generator() {
    yield 'hello';
    yield 'generator';
}

let cat = new Cat();

cat.says();
cat.setInfo({name: 'mini', color: 'black'});
cat.infos();

console.log([...generator()]);

export {
    cat,
    timeout
};