Overriding a function without removing static properties
问题 If I have a function like this: function a() { console.log('a'); } and then assign a static property like this: a.static = 'foo'; But say I want to override the function with another function like this: var old = a; a = function() { console.log('new'); old.call(this); }; a.static // undefined Since I assigned a new function to a , it’s static properties are lost. Is there a neat way to keep the static properties without looping and manually copying them? Update: Here’s a real world scenario: