InsideDarkWeb.com

What is the purpose of an empty value assignment in JavaScript (not null, undefined, etc)

I understand this:

let blah = null;
let blah = undefined;
let blah;

What I don’t understand is this:

    let obj = {}
      // notice the empty value assignment and the assignment that immediately follows
    obj.blah = 
    obj.blah = function(params) {
      // some code
    }

Is the empty assignment the same as let obj.blah;? I’ve seen this in a few npm packages where the key is provided a value directly beneath the empty value assignment of the same key. Is there a particular purpose to writing code this way? I’m refactoring a package to streamline its use, and I don’t want to simply delete this because of my ignorance. Any help will be greatly appreciated.

Stack Overflow Asked by user13443583 on November 15, 2021

1 Answers

One Answer

It's equivalent to

obj.blah = ( obj.blah = function () {} );

There's absolutely no reason to do that.

Answered by Quentin on November 15, 2021

Add your own answers!

Related Questions

Public API for all state tax names

1  Asked on January 31, 2021 by nitish

   

Remove event before remove DOM element everytime

1  Asked on January 31, 2021 by justanewcoder

       

lodash find returns only one result

1  Asked on January 31, 2021 by manuelbetancurt

     

api not call using dispatch

0  Asked on January 31, 2021 by codetribe

   

Reactjs using nginx not giving a 404

0  Asked on January 31, 2021 by keurig

       

Extract rows that have common values in R dataframe

3  Asked on January 31, 2021 by cirrus

     

Sum rows with same Id based on type and exlude where SUM = 0

1  Asked on January 31, 2021 by daniele-arrighi

   

CASE STATEMENT IN WHERE CLAUSE in QUERY

2  Asked on January 31, 2021 by sujeet-chaurasia

   

x86-16 imul instruction “wrong parameters”?

1  Asked on January 30, 2021 by vbvbvb123

     

Ask a Question

Get help from others!

© 2021 InsideDarkWeb.com. All rights reserved.