Access to a numerical key in a JavaScript object

Let's assume that we are working with the following object:

let highlights = {
    'year': {
        '0':  'You are born',
        '3':  'First day of school',
        '16': 'First day of high school',
        '18': 'College',
        '19': 'Meet Susan',
        '21': 'Dropout to work in your startup',
        '24': 'Startup fails',
        '25': 'Get a normal job',
        '27': 'Get married',
        '30': 'First kid',
        '65': 'Retirement',
        '66': 'You die suddenly because a heart stroke'

If we want to access to a numerical key in the object, we can do it like in arrays.


let highlight_19 = highlights.year['19'];

// 'Meet Susan'

Hi, I'm Erik, an engineer from Barcelona. If you like the post or have any comments, say hi.