const numToStr = (x, y) => `${x}x ${y}y`;
numToStr(2, 2); //'2x 2y'
const num = 42;
num + ''; //'42'
String(num); //'42'
const input = document.getElementById('input2');
input.addEventListener('focus', function() {
console.log('focus 2');
});
let id = 1;
$('.button').click(function() {
const node = $('.project').clone()[0];
node.id = `id${id++}`;
$(node).appendTo('body');
});
function pad(v) {
return 'id' + ('00' + v).slice(-3);
}
let id = 1;
$('.button').click(function() {
const node = $('.project').clone()[0];
node.id = pad(id++);
$(node).appendTo('body');
});
class Main {
constructor(el) {
this.el = el;
this.startDate = false;
}
init() {
if (this.el) this.el.addEventListener('click', this.onClickPrimaryEl.bind(this));
}
onClickPrimaryEl() {
const currentDate = Date.now();
if (this.startDate && (currentDate - this.startDate > 900000)) {
} else {
}
this.startDate = currentDate;
}
}
var timer1;
var timer2;
function timer1Func() {
timer1 = setTimeout(function() {
console.log('1st timer fired');
timer2Func();
}, 4000);
}
function timer2Func() {
timer2 = setTimeout(function() {
console.log('2nd timer fired');
timer1Func(); // Если не нужна цикличность, то удалите эту строчку.
}, 2000);
}
timer1Func();