Code = variable vs variable = code

Hey all - I’m trying to understand what’s happening in the following code block and a question popped in my head that I couldn’t make sense of. Here’s the code:

if (requestArticle && requestArticle.title && requestArticle.url &&
      requestArticle.username && database.users[requestArticle.username]) {
    const article = {
      id: database.nextArticleId++,
      title: requestArticle.title,
      url: requestArticle.url,
      username: requestArticle.username,
      commentIds: [],
      upvotedBy: [],
      downvotedBy: []
    database.articles[] = article;

It seems we’re defining the variable article as an object with a set of properties. But then below that, it’s almost as if we’re redefining article (which doesn’t make sense due to const syntax) as database.articles[]. What’s going on here? What is the difference between having code on one side of = vs the other?

Thank you!

The definition of the article object includes a unique generated id as one of its attributes,

The id becomes a key in the database.articles object, with the value assigned being the article object.

database = {
    articles = {
        %id% : {
            id: %id%,
            title: %article_title%,

So looking at the last two lines of code - am I think about this in the right way?

database.articles[] = article; is taking the unique value assigned in the const article object and adding it as it’s own key/property in the database.articles object.

Then we’re taking the value assigned in the article.username property and finding that same value as a key in database.users object. Then it’s drilling down into the articleIds array of that user and pushing the value of the property to that array.

Am I close?

Yes, that’s about right. articleIds is an index of articles by that particular user.