<template id="picture-template" style="display: none">
<a href="">
<img src="" width="182" height="182" class="pictures">
</a>
</template>
<div id="place"></div>
const template = document.querySelector('#picture-template').content;
const place = document.querySelector('#place')
const pictures = template.querySelector('.pictures');
for (let i = 1; i<25; i++ ) {
const pictureClone = pictures.cloneNode(true);
pictureClone.setAttribute('src', 'photos/' + i + '.jpg');
place.appendChild(pictureClone);
}
function findAll(haystack, needle) {
const str = haystack.toLowerCase();
const target = needle.toLowerCase();
const r = [];
let z;
for(let i = 0; i <= str.length; i++) {
if(!~(z = str.indexOf(target, i))) break;
r.push(z);
i = z + needle.length;
}
return r.length ? r : false;
}
function findAllTwo(str, target) {
let position = 0, z,
result = [];
while (~(z = str.indexOf(target, position))) {
result.push(z);
position = z + target.length;
}
return result;
}
for( let i = 0; ~(z = str.indexOf(target, i)); i++)
но это нечитабельно let perm = true;
const delay = 1000;
socket.on("notify", function (data) {
if (!perm) return;
perm = false;
setTimeout(() => perm = true, delay);
// here do actions
});
> (1e+21 / 100).toFixed(2)
'10000000000000000000.00'
> (1e+21 / 10).toFixed(2)
'100000000000000000000.00'
> (1e+21 / 1).toFixed(2)
'1e+21'
const time = "06:56 30.3.18"
function parseDate(dateString) {
if (!dateString) return new Date();
const regexp = /(\d+):(\d+)\s(\d+).(\d+).(\d+)/;
if(!regexp.test(dateString)) throw new Error('date string format error');
const d =regexp.exec(dateString);
if (d[5].length == 2) d[5] = `20${d[5]}`;
return new Date(d[5], d[4] - 1, d[3], d[1], d[2]);
}
const date1 = new Date(2018, 2, 30, 6, 56);
const date2 = parseDate(time);
console.assert(date1.getTime() == date2.getTime());
const set= new Set();
arrayOne.concat(arrayTwo).forEach(u => set.add(u));
arrayThree.concat(Array.from(set));
$(something.cells[n]).text()