// make sure it doesn't count my own properties
(function () {
var results, currentWindow,
// create an iframe and append to body to load a clean window object
iframe = document.createElement('iframe');
iframe.style.display = 'none';
document.body.appendChild(iframe);
// get the current list of properties on window
currentWindow = Object.getOwnPropertyNames(window);
// filter the list against the properties that exist in the clean window
results = currentWindow.filter(function(prop) {
return !iframe.contentWindow.hasOwnProperty(prop);
});
// log an array of properties that are different
console.log(results);
document.body.removeChild(iframe);
}());
class Express {
response = {}
middles = []
use = func => this.middles.push(func)
get = () => {
this.middles.forEach(func => func(this.response))
console.log('RESPONSE NOW: ',this.response)
}
}
app = new Express()
app.get()
// response: {}
function addBla(res) { res.bla = 17 }
// миддлвар добавляет какое-то свойство в response от сервера
app.use(addBla)
app.get()
// response: {bla: 17}
request('https://zachtronics.bandcamp.com/album/shenzhen-i-o-ost', function (error, response, body) {
res.send(body.match(/(?<=trackinfo:)(.*)(?=,)/gi))
// кривая регулярка, выцепляет не всё что надо
});
document.body.addEventListener('click', e => {
if(e.target.matches('.super-selector')) {
// e.target - кликнутый элемент
}
})
Array.prototype.myUnshift = function(...args) {
return [...this, ...args]
}
[3,5].myUnshift(34,52,25)
// [3, 5, 34, 52, 25]
data = [
{
id: 1,
title: 'NubeUnique',
description: 'Description of NubeUnique project',
content: '<span>Test<span> content for work item'
},
{
id: 2,
title: 'Performance',
description: 'Description of Performance project',
content: '<span>Test<span> content for work item'
},
{
id: 3,
title: 'Tabu',
description: 'Description of Tabu project',
content: '<span>Test<span> content for work item'
}
];
data.find(d => d.id === 2)
// {id: 2, title: "Performance", description: "Description of Performance project", content: "<span>Test<span> content for work item"}
html = ''
for (key in result.category) {
html += `<p>${key}</p><select>`
for (key1 in result.category[key].family) {
html += `<option>${key1}</option>`
}
html += `</select>`
}