typeof
будет равен "function" и для Object, String, Date, например — что не входит в ваши планы.callback && callback();
Object.prototype.toString.call(callback) === '[object Function]'
и для вас можно так:callback && Object.prototype.toString.call(callback) === '[object Function]' && callback();
curl
или школьным file_get_contents()
дергать некий локальный URL.inBetween(3, 6)
возвращает не строку, не число, а функкцию. var daFunc = inBetween(3, 6); // daFunc это функция
arr.filter(daFunc);
var daFunc = function() {
console.log(arguments);
}
arr.filter(daFunc);
1«Почти» — потому, что контекст тут другой будет. Всякие a
и b
не будут определены.function daFunc() { console.log(arguments); }
arr.filter(daFunc);
arr.filter( function() { console.log(arguments); });
arguments
там никакой не внешний / родительский / фильтрованный, а свой собственный.<span>поисковая строка</span>
. Жирноту/нежирноту сделать стилями. ipinfo.io
предоставляет API, есть бесплатный план (до 50 тыс. запросов в месяц)$.get("https://ipinfo.io", function(response) {
console.log(response.ip, response.country);
}, "jsonp")
{
"ip": "134.209.xxx.xxx",
"city": "Clifton",
"region": "New Jersey",
"country": "US",
"loc": "40.8344,-74.1377",
"org": "AS14061 DigitalOcean, LLC",
"postal": "07014",
"timezone": "America/New_York",
"readme": "https://ipinfo.io/missingauth"
}
var
переменная i
в любых вызовах навешанных функций имеет последнее своё значение из цикла, равное длине experimentElem
.var
на let
:for (let i = 0; i < experimentElem.length; i++) {
[...experimentElem].forEach((el, i) => {
el.addEventListener('mouseenter', event => gifElem[i].play());
el.addEventListener('mouseleave', event => gifElem[i].pause());
})
&code=xxxxx
, который уже мой сервер обменивает напрямую с соц.сетью на токен.postMessage()
в родительское окно с основным приложением – сообщит о результате: получено разрешение или пользователь что-то накосячил или передумал;.food-item-*
(может, у них у всех есть какой-то общий класс?) или document.querySelectorAll('[class^=.food-item-]')
.food-item-NNN-bin
(регуляркой) и выдирать оттуда число.new Phar('my_new_phar.phar')
создаёт новый архивProgressive Advancement has won the game for now as far as I can see. If UI/UX designers start a product design with its desktop version, they will inevitably want to make use of most of the advantages of the advanced end. For example, the hover effect which is supported by a cursor mouse; HD images & complex charts which can display normally only when there is a recent bandwidth. In this way, the designers will make efforts to complete an amazing desktop version and only to find it can hardly be adopted on a mobile end unless they give up a lot of beautiful ideas. If so, the mobile end version will be more like an afterthought, an incomplete product which’s been watered down.
active
для единственного выбранного элемента:div.answer { background: #222; color: #aeaeae; }
div.answer.active { background: #fff; color: #000; }
const els = [...document.querySelectorAll('.answer')];
const toggle = event => {
els.forEach(el => el.classList[event.target === el ? 'add' : 'remove']('active'));
}
els.forEach(el => el.addEventListener('click', toggle));