vadim9999 / js

2 stars 0 forks source link

es6 loops(for later) #4

Open atherdon opened 6 years ago

atherdon commented 6 years ago

https://hacks.mozilla.org/2015/04/es6-in-depth-iterators-and-the-for-of-loop/ https://www.tutorialspoint.com/es6/es6_loops.htm http://www.benmvp.com/learning-es6-for-of-loop/ https://gomakethings.com/looping-through-arrays-the-es6-way/

vadim9999 commented 6 years ago

I have learned about for-in and for-of loops. The for-in loop is for looping over object properties. The for-of loop is for looping over data.(value in array). The forEach is used in arrays. var list = [1,3,5]; list.forEach(function(value,index){ console.log(value); }) With for-of you can looping Set,Map, strongly recommended for Array. for-of is great because you can use in block code "return" "break" or "continue", but you don't do that in forEach. iterator const array =['foo','bar','zed']; const iterator = array[Symbol.iterator](); function return iterator with whom we can extract data from array. iterator.next() This function next() returns an object with properties value and done. Classification of loops Loops are Definite and Indefinit. Definite loop(for, for-in,for-of) are used to execute code certain times. Indefinit loops (while,do-while) are used to execute code when condition will be true, it's stops when it will be false. Loop Control statements: continue, label, break.

atherdon commented 6 years ago

some guys-experts are not happy with for-in operator. not sure if we'll use it, but good to know that you're read about it

On 03-Jul-2018 at 09:58 AM, Vadim wrote:

I have learned about for-in and for-of loops. The for-in loop is for looping over object properties. The for-of loop is for looping over data.(value in array). The forEach is used in arrays. var list = [1,3,5]; list.forEach(function(value,index){ console.log(value); }) With for-of you can looping Set,Map, strongly recommended for Array. for-of is great because you can use in block code "return" "break" or "continue", but you don't do that in forEach. iterator const array =['foo','bar','zed']; const iterator = arraySymbol.iterator; function return iterator with whom we can extract data from array. iterator.next() This function next() returns an object with properties value and done. Classification of loops Loops are Definite and Indefinit. Definite loop(for, for-in,for-of) are used to execute code certain times. Indefinit loops (while,do-while) are used to execute code when condition will be true, it's stops when it will be false. Loop Control statements: continue, label, break.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/vadim9999/js/issues/4#issuecomment-402087328, or mute the thread https://github.com/notifications/unsubscribe-auth/ABZrDpATvRM6AVCsOL4_OsPBaI2Db7egks5uC0BagaJpZM4U_Gx- .