Hello.

Take some function:

function DT.operators.Select(body, selectFrame, parentDiv) { this.body = body; this.selectFrame = selectFrame; this.parentDiv = parentDiv; } 

It can be called in two ways:

 DT.operators.Select(op1, op2, op3); // и var x = new DT.operators.Select(op1, op2, op3); 

And the question arises: what's the difference, except that in the second case, the pointer to the function is passed to the variable?
UPD1 :
How can I hide fields and functions?

    1 answer 1

    In the second case, a variable is created - an object of the class, with which you can continue to work.
    In the first case, all actions end on the first line.

     function DT.operators.Select(body, selectFrame, parentDiv) { this.body = body; var somePrivateVar = 'value';//приватное свойство. Аналогично объявляются приватные методы this.selectFrame = selectFrame; this.parentDiv = parentDiv; this.myfunc = function(){ alert('hello world'); return this;//Обратите внимание } this.myfunc2 = function(){ alert('good-bye world'); return this;//Обратите внимание } return this;//Обратите внимание } DT.operators.Select(op1, op2, op3).myfunc().myfunc2();//Все. В дальнейшем, доступ к этому объекту отсутствует. var x = new DT.operators.Select(op1, op2, op3); x.myfunc(); //some code x.myfunc2(); //Мы и дальше можем издеваться над этим иксом 
    • Please give a small example for clarity and a small explanation. And another thing: is it possible to conceal fields? - Anton Mukhin
    • He gave an example. - knes
    • Thank!!! Good explanation. - Anton Mukhin
    • I bet the blue elephant will now stick in and again it will post a simple and clear explanation of 3 lines. = /// - knes