+ 1
JavaScript yield
Knowledge about yield I know using yield in function* but what is const variableName = yield SOMETHING; What's it mean and how to create and use it
2 ответов
+ 2
I am not JavaScript student but found this article.I hope it clear your doubt.If not just ignore it
yield - JavaScript | MDN" https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/yield
Thank you🤗
+ 2
at least in javascript, yield is a two way communication with a generator:
yield something;
return something from generator, waiting for 'next' call to continue execution...
var value = yield something;
do the same thing, but fill value with the argument passed to 'next' method when called...
const fixed_value = yield something;
can only be executed once in the generator, as const declare constant variable (meaning you can assign it a value only once)
most of the time, you only need to be aware of yield something ;)