FoxPro Programming
Object.ADD( Obj ) overwritten, WTF?
oCollection = createobject('collection')
oEmpty = createobject('Empty')
addProperty(oEmpty,'mVar','')
oEmpty.mVar = 'string'
oCollection.Add(oEmpty)
oEmpty.mVar = ''
? oCollection(1)
Displays: mVar = ''
Why would setting mVar='' (empty string) effect the results of the object added to the collection?
What is the work-around to make the object added to the collection an independant from the local object?
If this was Angular a deep copy would be required, but this is VFP the User Friendly programming language!
Thanks, very helpful!
Now I understand what Rick wrote CopyObject...
any OOP language behaves the same:
var o = {}
var a = [o]
o['test'] = 'test'
console.log(a) // [Object { test="test"}]
being a framework, AngularJS may have implemented a 'clone object' method that you call 'deep copy'; any JS frameWork offers such a method.