When I print one of my objects (created via ajax calls) to the console I am getting back:
Object
discreet: Array[2]
range: Array[2]
__proto__: Object
But when I manually create the object I am correctly getting back:
Object {range: Array[2], discreet: Array[2]}
discreet: Array[2]
range: Array[2]
__proto__: Object
Could someone explain to me the difference between these two objects, and why I am unable to access the properties of the first object?
Edit: The first object is being created by:
var obj = {}
$http.get('/discreet').then( function(data) { obj.discreet = data } );
$http.get('/range').then( function(data) { obj.range = data } );
print(obj);
The second I am hand crafting:
var obj = { range: [1,2], discreet: [1,2] }
print(obj);
The first one is simply being printed before the xhr response has returned, so the object is empty at the time it is logged.
The second one is logged after it has been populated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With