function aaa() {
ย ย this.text = "aa";
ย ย this.objects = [this];
}
function bbb() {
ย ย this.text = "bb";
}
function context() {
ย ย this.state = new aaa();
ย ย this.text = function() {
ย ย ย ย return this.state.text;
ย ย }
}
context.prototype.setState = function(state) {
ย ย this.state = state;
}
var a = new aaa();
var b = new bbb();
var cont = new context();
console.log(cont.text());
cont.setState(b)
console.log(cont.text());
//output
aa
bb
์๋ ์ฐ๋ผ๋๊ฑฐ ์ง์..?
๋๊ธ 0