You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Certain specified behaviours of native constructors can't be simulated, such as setting the [[Class]] and [[PrimitiveValue]] properties. This prevents us from constructing an instance of these constructors with a nondeterministic number of arguments (as you would with apply normally). Here's how we can try to instantiate Date the way we would any other constructor with a dynamic set of arguments:
+function(ctor,args){vartmpCtor=function(){};tmpCtor.prototype=ctor.prototype;varobj=newtmpCtor;varresult=ctor.apply(obj,args)returnObject(result)===result ? result : obj;}(Date,[1990,01,01]);
You would expect this to produce 633852000000, but because it doesn't have a [[PrimitiveValue]], it throws the error
TypeError: this is not a Date object.
at Date.valueOf (native)
[...]
The text was updated successfully, but these errors were encountered:
Certain specified behaviours of native constructors can't be simulated, such as setting the
[[Class]]
and[[PrimitiveValue]]
properties. This prevents us from constructing an instance of these constructors with a nondeterministic number of arguments (as you would withapply
normally). Here's how we can try to instantiateDate
the way we would any other constructor with a dynamic set of arguments:You would expect this to produce
633852000000
, but because it doesn't have a[[PrimitiveValue]]
, it throws the errorThe text was updated successfully, but these errors were encountered: