Skip to content

How to differentiate between JS "For....in" and "For...of"? #208

Answered by jaredcwhite
esb asked this question in Q&A
Discussion options

You must be logged in to vote

@esb The functions filter, which is in the default preset, automatically converts Ruby's each to for...of:

arr = [1,2,3,4]

arr.each do |item|
  puts item
end

turns into

let arr = [1, 2, 3, 4];

for (let item of arr) {
  console.log(item)
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@esb
Comment options

Answer selected by esb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants