function Rabbit() {}
console.log(Object.getOwnPropertyDescriptor(Rabbit, 'prototype')); // { value: {}, writable: true, enumerable: false, configurable: false }
class Rabbit {}
console.log(Object.getOwnPropertyDescriptor(Rabbit, 'prototype')); // { value: {}, writable: false, enumerable: false, configurable: false }
'use strict';
Rabbit.prototype = {};
TypeError: Cannot assign to read only property 'prototype' of function 'class Rabbit {}'
В объекте "obj" замыкаается только name (так как оно используется)? Или все остальное так-же?
'use strict';
function factory() {
const var1 = 111;
const var2 = 222;
const var3 = 333;
return {
test: function (code) {
eval(code);
}
};
}
const obj = factory();
setTimeout(function () {
obj.test('console.log(var1);');
}, 5000);
setInterval(function () {
global.gc();
});
node --expose-gc test.js
`${process.execPath}/db.sqlite3`
const Promise = require('bluebird');
let results = await Promise.map(filteredMatches, v => handler(v.CI), { concurrency: 10 });
'use strict';
const { Queue } = require('plain-queue');
const queue = new Queue;
// внутри async function
chat.quiz = global_quizzes[quiz_id];
if(!chat.quiz) {
chat.quiz = await queue.addTask(function () {
return global_quizzes[quiz_id] || Chat_Quizzes.findById(quiz_id).exec();
});
global_quizzes[quiz_id] = chat.quiz;
}