const Product = function(){
var counter = 0;
this.incrementCount = (c=1) =>
counter+=c;
this.getCount = () => counter;
}
let product = new Product();
product.incrementCount();
console.log(product.getCount());
//1
product.incrementCount(2);
console.log(product.getCount());
//3
let menu = {
width: 200,
height: 300,
title: "My menu"
};
console.log( JSON.stringify(menu) );
function multiplyNumeric(obj) {
for (let key in obj) {
if (typeof obj[key] == 'number') {
obj[key]*=2;
}
}
}
multiplyNumeric(menu);
console.log(menu);
const bot = new Botact({
...,
redis: true // enable redis
flowTimeout: 20 // timeout for delete documents
redisConfig: { // redis config
port: 1234
}
})
bot.catch((ctx, err) => {
// ctx - user's context
// err - throwed error
console.error(ctx, err)
})
for (var element of document.querySelectorAll('.answer') )
let block = element.querySelector(".hidden_info");
let btn = element.querySelector(".btn");
let btnTwo = element.querySelector(".btnTwo");
btn.onclick = function (){
block.style.display = "block";
btn.style.display = "none";
btnTwo.style.display = "inline";
}
btnTwo.onclick = function (){
block.style.display = "none";
btn.style.display = "inline";
btnTwo.style.display = "none";
}
}
<?php if( isset($_SESSION['logged_user']) ) : ?>
<div class="head-el-one">
<p onmouseover="vsplil.show('<?= $notifications ?>', this.offsetLeft, this.offsetTop);"
onmouseout='vsplil.hide()'>
<ion-icon name="megaphone"></ion-icon>
</p>
<div class="top_notify_count">1</div>
</div>
<script>
function podskazka() {
console.log('initialized');
this.show = function(text,x,y) {
console.log(`show notify " ${text} " at ${x + ' ' + y}`);
var div = document.createElement('div');
div.className = 'podskazka';
div.id = 'metka';
div.innerHTML = text;
var koordx = x - 215;
var koordy = y + 50;
div.style.left = koordx + 'px';
div.style.top = koordy + 'px';
document.body.appendChild(div);
}
this.hide = function() {
var metka = document.getElementById('metka');
metka.parentNode.removeChild(metka);
}
}
var vsplil = new podskazka();
</script>
let regex=/^\S.{0,18}\S$/g
refresh метод пробовали?