console.log() shows the changed value of a variable before the value actually changes

后端 未结 7 2001
无人共我
无人共我 2020-11-22 02:09

This bit of code I understand. We make a copy of A and call it C. When A is changed C stays the same

var A = 1;
var C = A;
console.log(C); // 1
A++;
console.         


        
相关标签:
7条回答
  • 2020-11-22 03:00

    Though it's not going to work in every situation, I ended up using a "break point" to solve this problem:

    mysterious = {property:'started'}
    
    // prints the value set below later ?
    console.log(mysterious)
    
    // break,  console above prints the first value, as god intended
    throw new Error()
    
    // later
    mysterious = {property:'changed', extended:'prop'}
    
    0 讨论(0)
提交回复
热议问题