正在学习Decorator,发现在定义Decorator时,有的函数会返回propertyDescriptor,有的不返回。那么到底哪些需要返回,还是说返不返回影响不大?
返回了PropertyDescriptor的Decorator:
function readonly(target, name, descriptor){
descriptor.writable = false;
return descriptor;
}
没返回PropertyDescriptor的Decorator:
function testable(target) {
target.isTestable = true;
}