function LateBloomer() {
this.petalCount = Math.ceil(Math.random() * 12) + 1;
}
LateBloomer.prototype.bloom = function () {
window.setTimeout(this.declare, 2000)
// window.setTimeout(() => this.declare() ,2000)
}
LateBloomer.prototype.declare = function () {
console.log(`I am a beautiful flower with ${this.petalCount} petals`);
}
var flower = new LateBloomer();
flower.bloom();
//
下面的代码定义了一个LateBloomer构造函数,但是打印结果却和预期不一样, 你能修复么?并说明为什么?
body{
background:#fff;
}