Accessing something inside the object when you don't know the key

You can get the values from object and than access the desired key.

let obj =  {
    IuW1zvaSABwH4q: 
      {
        label: 'Random Image of TypeScript not relavent to coworking', 
        thumbId: 'd501-f-b601-c8b1-4bd995e',
        schemaType: 'xman-assets-image-set' 
      } 
    }
    
let op = Object.values(obj)[0].thumbId

console.log(op)


You can use Array.map to transform it and Array.forEach to get it and print it in the console.

const obj = {
    IuW1zvaSABwH4q: {
        label: 'Random Image of TypeScript not relavent to coworking',
        thumbId: 'd501-f-b601-c8b1-4bd995e',
        schemaType: 'xman-assets-image-set'
    },
    YuW1zvaSABwH7q: {
        label: 'Random Image of TypeScript not relavent to coworking',
        thumbId: 'as90-f-b601-c8b1-4bd9958', 
        schemaType: 'xman-assets-image-set'
    }
};
//for one object
console.log(Object.values(obj)[0].thumbId);
//multiple unknown keys
Object.values(obj).map(ele => ele.thumbId).forEach(th=> console.log(th));


Assuming there is only one property you could access it via the first property.

const obj = { IuW1zvaSABwH4q: 
      { label: 'Random Image of TypeScript not relavent to coworking', thumbId: 'd501-f-b601-c8b1-4bd995e', schemaType: 'xman-assets-image-set' 
       } 
    };
    
console.log(obj[Object.getOwnPropertyNames(obj)[0]].thumbId);

Tags:

Javascript