en.javascript.info/1-js/6-objects-more/3-static-properties-and-methods/1-objects-counter/task.md
Ilya Kantor 87bf53d076 update
2014-11-16 01:40:20 +03:00

33 lines
792 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Счетчик объектов
[importance 5]
Добавить в конструктор `Article`:
<ul>
<li>Подсчёт общего количества созданных объектов.</li>
<li>Запоминание даты последнего созданного объекта.</li>
</ul>
Используйте для этого статические свойства.
Пусть вызов `Article.showStats()` выводит то и другое.
Использование:
```js
function Article() {
this.created = new Date();
*!*
// ... ваш код ...
*/!*
}
new Article();
new Article();
Article.showStats(); // Всего: 2, Последняя: (дата)
new Article();
Article.showStats(); // Всего: 3, Последняя: (дата)
```