Suppose we'd like to invoke the JavaScript function JSON.stringify
which receives an object, encodes it into a JSON string and returns it.
All we'd have to do is write the function signature, mark it as external and annotate it with the @JS
annotation:
@JS("JSON.stringify")
external String stringify(obj);
The @JS
annotation will be used from here on out to mark Dart classes that we'd like to use in JavaScript as well.