News from the Field
A channel with tips on modern AI development. Join!
⊗jsPmFCATV 266 of 504 menu
◀ ▶

Assignment function to a variable in JavaScript

Now let our locally called function doesn't display something to the console, but returns it via return:

+function() { return '!'; }();

Let's assign the result of our function to a variable and print it to the console. Since in this case there is an assignment to a variable, the plus is no longer needed:

let result = function() { return '!'; }(); console.log(result); // shows '!'

Determine what will be output to the console without running the code:

let result = function() { return '!'; }(); console.log(result);

Determine what will be output to the console without running the code:

let result = function() { return '!'; }; console.log(result);

Determine what will be output to the console without running the code:

let result = function() { return '!'; }; console.log(result());
← →
↑
English▼
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline