confused about timing and resolutions | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

confused about timing and resolutions

I'm confused with timing and vocabulary... var a=0 //got it let b=++a /*so "a"gets increased to 1 when? before "b"is given a value? So theoretically a=1before the line of code is even read?*/ let c=a++ /*so "c" is 1 because you don't add 1to a until after the line of code is resolved? But still prior the print operation?

19th Jun 2017, 4:46 PM
Corey Kachinski
Corey Kachinski - avatar
2 Answers
+ 2
Your conclusions are wrong while your understanding is correct. let b= ++a; this is a 2 step operation. first a is incremented and then b is assigned the updated value. so a <> 1 before this line. let c = a++; again 2 steps. c is assigned the current value of a and then a is incremented.
20th Jun 2017, 9:19 PM
Gurpreet Singh
Gurpreet Singh - avatar
0
Ok! That makes so much more sense!
20th Jun 2017, 10:08 PM
Corey Kachinski
Corey Kachinski - avatar