you won’t get a shallow copy (it also checks the prototype chain, it does not loop over non-enumerable properties and it skips null/undefined values).
the method of choice would be Object.getOwnPropertyNames()
. and for setting the properties for the new object, you can use Object.defineProperty() and Object.getOwnPropertyDescriptor().
I would recommend not to attach them to
, unless your function is an object’s method (because simply calling the function would attach the properties to the