Arrow function - lack of curly brackets in single line block

When writing an arrow function with a single line in the function block, the block will run 4 times if curly brackets are missing.


web.init();‘website 1 url’);
web.execute(()=> {‘website 2 url’)

In this case- opens website once

web.init();‘website 1 url"’);
web.execute(()=>‘website 2 url’));

In this case- opens four tabs of website 2

btw - couldn’t write real url since this forum doesn’t allow new users to post more than 2 links in a thread

Omitting curly brackets in this specific case is identical to adding a return before, so the following two expressions are identical:

web.execute(() =>''));

is identical to:

web.execute(() => {return'');});

When this executed, web.execute will run in the browser and will try to return the value returned by
However, returns an object which cannot be serialized and passed back from the browser. Trying to return un-serializable objects might lead to some strangeness, like multiple tabs opening/closing in this case.

Why 1st variant works then? Because it doesn’t return anything:

web.execute(()=> {‘website 2 url’)});

is identical to:

web.execute(()=> {‘website 2 url’); return; });