function Article() { Article.count++; //... } Article.count = 0; Article.showCount = function() { alert( this.count ); // (1) } // использование new Article(); new Article(); Article.showCount(); // (2) 

  • No, it does not. What place in the code makes you suspicious? - Igor
  • @Igor if count ++ is there and we have not announced it, will the search be in the window correctly? - xes 10:35 pm
  • @meine I'm aware of the closure I asked because the Article () function; function - constructor - xes pm
  • one
    @Igor I seem to understand what is happening in the code 1) function is an object 2) there is no difference what syntax we use literal or not; 3) we assigned to caunt = 0; 4) Article.count ++; Reference Type is used here. does the number increase correctly? - xes

1 answer 1

There is no closure in this code.

A function in js is an object. You have created a property for this object.

 Article.count = 0; 

When calling this function (no matter how constructor or not) the value of this property increases.

When calling

 Article.showCount(); 

this inside showCount is an Article function / object that has a count property you created.