call moves the hidden this to a self parameter (ie: rust).
apply moves the parameters tuple list to a tuple or fixed array.
bind moves the hidden this to a self and creates a context using it.
this is the object it was called upon; or undefined in toplevel strict mode.
arrow functions consume only arguments and context, and do not have a this context of their own. In rust the closest is a closure with move. This is normal.
These can be composed in insane ways:
constfbind=fn=>Function.prototype.call.bind(fn);
In this case, I move the this hidden parameter into the self leading parameter. I use this a lot actually... my typescript for it is
Reflect.apply adds a dynamic dispatcher (function) option.
Reflect.construct adds a class dispatcher (class/new) option.
Proxy { apply() {} } is the inverse of Reflect.apply; and can be heavily reused in children.
same in Proxy { construct() {} }
Adding getters and setters:
get a() {} returns some value representing a; which may be a constant or variable or an internal value. This can also have side effects...
set a(val) {} returns void (undefined) and sets a; or else throws when there's some issue with val. For example, checking Number.isInteger(val) and throwing when it fails. Side effects allowed here as well...
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
May as well do it:
call
moves the hiddenthis
to aself
parameter (ie: rust).apply
moves the parameters tuple list to a tuple or fixed array.bind
moves the hiddenthis
to aself
and creates a context using it.this
is the object it was called upon; or undefined in toplevel strict mode.this
context of their own. In rust the closest is a closure withmove
. This is normal.These can be composed in insane ways:
In this case, I move the
this
hidden parameter into theself
leading parameter. I use this a lot actually... my typescript for it isFurthermore, including
Reflect
andProxy
:Reflect.apply
adds a dynamic dispatcher (function) option.Reflect.construct
adds a class dispatcher (class/new) option.Proxy { apply() {} }
is the inverse ofReflect.apply
; and can be heavily reused in children.Proxy { construct() {} }
Adding getters and setters:
get a() {}
returns some value representinga
; which may be a constant or variable or an internal value. This can also have side effects...set a(val) {}
returns void (undefined) and setsa
; or else throws when there's some issue withval
. For example, checkingNumber.isInteger(val)
and throwing when it fails. Side effects allowed here as well...