Skip to content

A Question on Closure with Javascript #177

Answered by AllanRegush
jomefavourite asked this question in Q&A
Discussion options

You must be logged in to vote
@Allan Regush my main question is why does it log 6 each time, even when the function value called changes?

jomefavourite:

When the function is called a second time the counter is greater then 0.
So we don’t reassign the onceVal variable.

Replies: 3 comments 2 replies

Comment options

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

Comment options

You must be logged in to vote
0 replies
Comment options

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

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