let a = 'true';
if (typeof(a) === 'string'
|| typeof(a) === 'boolean'
|| typeof(a) === 'number'
){
console.log(typeof(a));
} else {
console.log('Тип а не определен');
}
let a = 'true';
if ( ['string', 'boolean', 'number'].includes(typeof(a)) ){
console.log(typeof(a));
} else {
console.log('Тип а не определен');
}
let a = 'true';
if (typeof(a) === 'string'){
console.log(a + ' - строка');
} else if (typeof(a) === 'boolean') {
console.log(a + ' - логический тип');
} else if (typeof(a) === 'number') {
console.log(a + ' - число');
} else {
console.log('Тип а не определен');
}
let a = 'true';
switch (typeof(a)) {
case 'string':
console.log(a + ' - строка');
break;
case 'boolean':
console.log(a + ' - логический тип');
break;
case 'number':
console.log(a + ' - число');
break;
default:
console.log('Тип а не определен');
}
file_get_contents("https://api.telegram.org/bot".$TOKEN."/sendMessage?chat_id=".$ID."&text=".urlencode($message));
#form-registry input:invalid .button
– это бессмысленный селектор. Input не может содержать внутри себя другие элементы.#form-registry input:invalid {
.button {
pointer-events: none;
}
}
#form-registry input:invalid {
&.button {
pointer-events: none;
}
}
#form-registry input:invalid + .button
Array.prototype.amount = function() {
return this.reduce((a, i) => a + Number(i), 0);
}
let nums = 123123;
let arr = `${nums}`.split('');
const sum1 = arr.slice(0, 3).amount();
const sum2 = arr.slice(3, 6).amount();
if (sum1 == sum2) {
console.log('сумма первых цифр равняется остальным трём');
} else {
console.log('нет, не равняется');
}
<link id="theme" href="templates/gor/css/light.css">
function setTheme(theme) {
document.getElementById('theme').setAttribute('href', `templates/gor/css/${theme}.css`);
}
$('.getlight').on('click', function () {
setTheme('light');
localStorage.setItem('selectedTheme', 'light'); // Запомнить
});
$('.getdark').on('click', function () {
setTheme('dark');
localStorage.setItem('selectedTheme', 'dark'); // Запомнить
});
const selectedTheme = localStorage.getItem('selectedTheme') ?? 'light';
setTheme(selectedTheme);