Skip to content

Regarding the offset field in OP_for_of_next instruction #1108

Answered by bnoordhuis
meetesh06 asked this question in Q&A
Discussion options

You must be logged in to vote

OP_for_of_next’s offset field [..] Does a non-zero value ever happen?

Yes, with destructuring spreads. Example:

function f(a = []) {
  let [...b] = a
}

Translates to bytecode like this:

// ...
for_of_start
array_from 0
push_0
for_of_next 2 // |a| is at depth 2
// ...

Replies: 1 comment 1 reply

Comment options

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

Answer selected by meetesh06
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