T
T
TrainHard2015-09-20 19:27:37
JavaScript
TrainHard, 2015-09-20 19:27:37

How does this construct work in JavaScript?

Hello!
Please explain in simple terms.
How does this construct work in JavaScript?

var module = (function (obj) {	
  //code
})(module || {});

I'm completely confused. Thank you.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vitaly Inchin ☢, 2015-09-20
@In4in

So it will be more clear?

function f(obj){
  //code
}
var module = f(f() || {});

S
Sergey, 2015-09-20
Protko @Fesor

Design Pattern Module

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question