In JavaScript, Objects are order-agnostic, so there's no guaranteed way to make sure that the first attribute will be what you want. There's two options for you as I see it...
Option 1: use an array instead
var example = [
{ /* stuff1 */},
{ /* stuff2 */},
{ /* stuff3 */}
];
Now you can safely acces the first object with `example[0].
Option 2: use Object.keys
Object.keys
will create an array out of all the keys (attributes, as you put it) in the object. So using your example, it would loke like this:
var example = {
'att1': { /* stuff1 */},
'att2': { /* stuff2 */},
'att3': { /* stuff3 */}
};
// This will produce this array: ['attr1','attr2','attr3']
var keys = Object.keys(example)
So with keys
now being an array of all the objects property names, if (and if being the focus here) you know the specific name you're looking for you can just loop over keys until you find it like so:
keys.map(function(key) {
if(key === 'attr1') {
/* do something with example[key] */
}
});
Hope this helps!