SOURCE

console 命令行工具 X clear

                    
>
console
//  'Output in HTML', assigned to out1
let out1='';

const console= {};
console.log= (msg)=>{
      out1+= msg + '<br>';
}

// ES6 getter and setter

class Car{
    constructor(model='', color='', age=0){
        this.model= model;
        this.color= color;
        this.age= age;
    }

    set condition(condition={}){
        try{
            if(condition){
                for (const prop in condition) {
                    if (!this.hasOwnProperty(prop)) throw new TypeError('property type error');
                    this[prop]= condition[prop];
                }
            }
        } catch(e){
            console.log(e.message);
        }
    }

    get condition(){
        return `${this.model} - ${this.color} - ${this.age} years old`;
    }
}

let ford= new Car('Mustang','blue',5);
console.log(ford.condition);

ford.condition={age:10};

console.log(ford.condition);

ford.condition={modell:'fusion', age:10};

console.log(ford.condition);


document.querySelector('#output').innerHTML = out1;
        <div class='container'>
            <div id='output'>
              <h1 style='color: white;'> Switch to Dark Theme to see the result</h1>
                            <h1 style='color: Black;'> Switch to Dark Theme to see the result</h1>
            </div>
        </div>
body{
    background: #FCFCFC;
}