From b7209f81866c783676d3e7b58bee5bbbfb1260fa Mon Sep 17 00:00:00 2001 From: Hauke D Date: Sun, 2 Sep 2018 18:06:04 +0200 Subject: [PATCH] Added documentation for js_new() haukex/emperl5@a0cc701354a6fb715257017a338f7fa1be5acf85 --- using.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/using.md b/using.md index 67f4905..a9ad921 100644 --- a/using.md +++ b/using.md @@ -344,6 +344,7 @@ It also provides the functions `unregister`, `sub_once`, and `sub1` in ["Memory Management and Anonymous `sub`s"](#memory-management-and-anonymous-subs). For convenience, it can also re-export `encode_json`, so you can request it directly from `WebPerl` instead of needing to `use` another module. +Additional functions, like `js_new()`, are documented below. All functions are exported only on request. Note that WebPerl will also enable autoflush for `STDOUT`. @@ -440,6 +441,21 @@ future be extended to return more than that, similar to `WebPerl::js()`, and then the passing of Perl values to JavaScript could be accomplished differently as well. +### `js_new()` + +This function is a convenience function for calling JavaScript's `new`. +The first argument is the name of the class, the following arguments are +passed to the constructor. It returns the same thing as the `js()` function, +in this case that would be the new object. For example: + + js_new('Blob', [""], {type=>"text/html;charset=utf-8"}) + +is the same as calling this in JavaScript: + + new Blob([""], {type:"text/html;charset=utf-8"}) + +This function was added in WebPerl `v0.05-beta`. + ***