Changes between Initial Version and Version 6 of Ticket #4257


Ignore:
Timestamp:
Aug 16, 2017, 6:36:43 PM (7 years ago)
Author:
elexis
Comment:

Exemplary JS code for recursive freezing (deep-freeze) is described at:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze

It should be added to globalscripts/utility.js as it is needed in both simulation and GUI.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #4257

    • Property Milestone BacklogAlpha 23
  • Ticket #4257 – Description

    initial v6  
    33However, returning an object means that the reference is returned, not a copy. This isn't an issue if that object was newly created (or cloned). But if the function returns an object which is accessible outside of the scope of the function (f.e. a global cache variable), modifying the returned object modifies the cache, which is not intentional and adulterates the original data.
    44
    5 This is often not considered and has caused a number of bugs already, f.e. r18788 r17324 r17441 r17712 r17715.
     5This is often not considered and has caused a number of bugs already, f.e. r18788 r17324 r17673 r17441 r17712 r17715.
    66
    77The mentioned functions should use `Object.freeze` to ensure that the returned object can't be modified.