JSObjectUnsafeUtilExtension#
Utility methods to check, get, set, and call properties on a JSObject.
See the JavaScript specification for more details on using properties.
Methods#
callMethod() extension#
Calls method on this JSObject
with up to four arguments.
Returns the result of calling method, which must be an R.
This helper doesn't allow passing nulls, as it determines whether an argument is passed based on whether it was null or not. Prefer callMethodVarArgs if you need to pass nulls.
Available on JSObject, provided by the JSObjectUnsafeUtilExtension extension
Implementation
R callMethod<R extends JSAny?>(
JSAny method, [
JSAny? arg1,
JSAny? arg2,
JSAny? arg3,
JSAny? arg4,
]) => _callMethod(method, arg1, arg2, arg3, arg4) as R;
callMethodVarArgs() extension#
Calls method on this JSObject
with a variable number of arguments.
Returns the result of calling method, which must be an R.
Available on JSObject, provided by the JSObjectUnsafeUtilExtension extension
Implementation
R callMethodVarArgs<R extends JSAny?>(
JSAny method, [
List<JSAny?>? arguments,
]) => _callMethodVarArgs(method, arguments) as R;
delete() extension#
Deletes the property with key property from this JSObject.
Uses JavaScript's delete to delete the property.
Available on JSObject, provided by the JSObjectUnsafeUtilExtension extension
Implementation
external JSBoolean delete(JSAny property);
getProperty() extension#
The value of the property key property of this JSObject.
Available on JSObject, provided by the JSObjectUnsafeUtilExtension extension
Implementation
external R getProperty<R extends JSAny?>(JSAny property);
has() extension#
Shorthand helper for hasProperty
to check whether this JSObject
contains the property key property, but takes and returns a Dart value.
Available on JSObject, provided by the JSObjectUnsafeUtilExtension extension
Implementation
bool has(String property) => hasProperty(property.toJS).toDart;
hasProperty() extension#
Whether or not this JSObject
contains the property key property.
Uses JavaScript's in to check.
Available on JSObject, provided by the JSObjectUnsafeUtilExtension extension
Implementation
external JSBoolean hasProperty(JSAny property);
setProperty() extension#
Write the value of property key property of this JSObject.
Available on JSObject, provided by the JSObjectUnsafeUtilExtension extension
Implementation
external void setProperty(JSAny property, JSAny? value);
Operators#
operator []() extension#
Shorthand helper for getProperty
to get the value of the property key
property of this JSObject, but takes a Dart value.
Available on JSObject, provided by the JSObjectUnsafeUtilExtension extension
Implementation
JSAny? operator [](String property) => getProperty(property.toJS);
operator []=() extension#
Shorthand helper for setProperty
to write the value of the property
key property of this JSObject, but takes a Dart value.
Available on JSObject, provided by the JSObjectUnsafeUtilExtension extension
Implementation
void operator []=(String property, JSAny? value) =>
setProperty(property.toJS, value);