JavaScript: Difference between revisions
Line 93: | Line 93: | ||
===Promises=== | ===Promises=== | ||
Added in ES2015 (ES6)<br> | |||
See [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise Promises]<br> | See [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise Promises]<br> | ||
In general, a function returns a promise if it needs to perform asyncronous tasks.<br> | In general, a function returns a promise if it needs to perform asyncronous tasks.<br> | ||
Line 114: | Line 115: | ||
}); | }); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
===Async-await=== | |||
Added in ES2017<br> | |||
See [https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous/Async_await Async_await]<br> | |||
Async functions return implicit promises. They allow you to use keyword <code>await</code> to get results from other promises or functions. | |||
==Compilation== | ==Compilation== |