this is useful when you want to access bound-methods of an instance of a class, such as the ones declared as:
classX { methodOfProto() { } }
these bound methods are not available via destructure of an instance, because they then lose their this context.
the only functions that can be destructured without losing their this context are the ones declared via assignment:
constslow_push_to_arr = (...values: number[]) => (arr.push(...values)) // the following declaration is more performant than `slow_push_to_arr`, // and it also has lower memory footprint. constfast_push_to_arr = array_proto.push.bind(arr)
get the prototype object of a class.
this is useful when you want to access bound-methods of an instance of a class, such as the ones declared as:
these bound methods are not available via destructure of an instance, because they then lose their
this
context. the only functions that can be destructured without losing theirthis
context are the ones declared via assignment:Example