func (r *Runtime) object_getPrototypeOf(call FunctionCall) Value {
- o := call.Argument(0).ToObject(r)
+ t := call.Argument(0)
+ if t == _null || t == _undefined {
+ return _null
+ }
+ o := t.ToObject(r)
p := o.self.proto()
if p == nil {
return _null
}
return p
}
See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf#return_value
In current state, If the obj is null it will throw an error when we call ToObject.
value.go#L425
Instead of that, We just check the obj before to call ToObject to avoid the error.
builtin_object.go#L22