There is something like this:
var request = new function(){ var jsonAjaxResult, countOfDownloadingArts; function downloadArts(){ return Promise((resolve, reject) => { // Код для загрузки картинок }); } function downloadJSON(){ return Promise((resolve, reject) => { // Код для загрузки json-а }); } this.getNewArts = (numberOfShowingArts = 20) => { // Обработчик очереди возвращающихся промисов для загрузки // заданного количества картинок (формальный параметр) } } In it, I use methods like this:
request.getNewArts(40); Very convenient.
But when I write this kind of construct, jsLint swears this error:
Weird construction. Is 'new' necessary? Well, I'm wondering why I can't use an anonymous function as a constructor? As I understand it, this is simply ugly from the point of view of logic, but I really need one copy of this functionality.
How then to be? To make a mistake or can I somehow rewrite the code?
Honestly, I would like it to be like this:
function request(){ // функции и переменные } // И использовать вот так: request.getNewArts(40); But alas, in js as impossible, as I understand it.