具有以下课程:
class notificationProcessor {
constructor() {
this.availableIcons = {
notification: "envelope",
purchase: "cart"
};
}
static purchaseGrowlNotification(notificationToUse) {
console.log(notificationToUse);
}
}
//first approach
notificationProcessor.purchaseGrowlNotification((new notificationProcessor()).availableIcons.notification);
//second approach
let tempObject = new notificationProcessor();
notificationProcessor.purchaseGrowlNotification(tempObject.availableIcons.notification);
哪种方法可以调用此静态函数更好=占用更少的内存?是
(new notificationProcessor())
对象在使用字段后死亡?
我知道还有其他方法可以解决此问题,但是我专注于创建封装模型。