'How to create object with a variable as a property name?

i have noob question, but couldn't find answer. Probably don't know what exactly to google.

I need to return an object like that, but it doesn't let me:

return {
      ...convo,
      messages: readMessagesCopy, 
      numberOfUnreadMessages: {},
      lastReadMessages: {readMessagesCopy[readMessagesCopy.length-1].senderId : readMessagesCopy[readMessagesCopy.length-1]}
    }

What's the right way of doing it? Thanks a lot!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source