Uploaded image for project: 'VS Code Extension'
  1. VS Code Extension
  2. VSCODE-355

print() output in playgrounds is affected by mutations

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 0.9.5
    • Component/s: Playgrounds
    • 3

      https://mongodb.slack.com/archives/CUKTSEB6J/p1673269054642729

      In a Plaground, the following piece of code prints out the same date twice - always, if I comment out the second print the first date is printed correctly, can someone explain why as it's not the JS behaviour I expect.

      firstdate = new ISODate('2016-01-01')
      print(firstdate)
       firstdate.setDate(firstdate.getDate() + Math.floor(Math.random()*100));
       print(firstdate)
      

      What happens here is that the JS values that are printed are stored and then sent to the output window as one batch when the script has finished executing, and so mutations at later points in the code affect the output

            Assignee:
            gaurab.aryal@mongodb.com Gaurab Aryal
            Reporter:
            anna.henningsen@mongodb.com Anna Henningsen
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: