-
Fototrend
JavaScript != Java (A JavaScript nem összekeverendő a Javával, két különböző programozási nyelvről van szó!)
Új hozzászólás Aktív témák
-
Jim-Y
veterán
válasz
martonx
#5452
üzenetére
Felig meddig igazad van, a typeof az onmagaban broken es tipus vizsgalatra nem javallott. Egy dologra alkalmas, undefined vizsgalatra
Bar en arra is inkabb explicitebb megoldast valasztanek pl
valami === void 0 de ez egyeni preferencia.Kb jQuery + underscore + lodash-bol osszeollozva
function isString(obj) {
return $.type(obj) === 'string';
}
function isNumber(obj) {
return exist(obj) && $.isNumeric(obj);
}
function isBoolean(obj) {
return obj === true || obj === false || $.type(obj) === 'boolean';
}
function isArray(obj) {
return exist(obj) && $.isArray(obj);
}
function isFunction(obj) {
return $.type(obj) === 'function';
}
function isDate(obj) {
return $.type(obj) === 'date';
}
function isRegExp(obj) {
return $.type(obj) === 'regexp';
}
function isError(obj) {
return toString.call(obj) === '[object Error]';
}
function isUndefined(obj) {
return obj === void 0;
}
function isNull(obj) {
return obj === null;
}
function isEmpty(obj) {
if (!exist(obj)) {
return true;
}
if (isNumber(obj) || isBoolean(obj) ) {
return false;
}
if (isArray(obj) || isString(obj) || toString.call(obj) === '[object Arguments]') {
return obj.length === 0;
}
return $.isEmptyObject(obj);
}
function exist(obj) {
return !isNull(obj) && !isUndefined(obj);
}
Új hozzászólás Aktív témák
- Ryzen 7 3700X / RTX 2060 SUPER / 32GB RAM / 512GB NVMe Gamer PC
- Beszámítás! Motorola Sound Flow XT2549-1 hangszóró hibátlan működéssel
- Beszámítás! Lenovo Thinkpad P15 Gen 1 FHD notebook - i7 10850H 32GB DDR4 1TB SSD T2000 4GB W11
- Beszámítás! Samsung Galaxy S23 Ultra 256GB okostelefon garanciával hibátlan működéssel
- Samsung Galaxy S23 Plus 5G (8/512 GB) független, garanciás 210 000 Ft
- GYÖNYÖRŰ iPhone XR 64GB Black -1 ÉV GARANCIA - Kártyafüggetlen, MS4270, 100% Akkumulátor
- Dell Pro Plus 14 Core Ultra 5 238V 32GB 1000GB FHD+ TouchScreen ProSupport Plus gar: 2028.10.07
- ÚJ BONTATLAN Apple Macbook Air 15,3 M4 10C CPU/10C GPU/16GB/256GB - Égkék - HUN - mc7a4mg/a 3 év gar
- Akciós! Lenovo ThinkPad P15 Gen 1 Intel i7-10875H 32GB 512GB Nvidia Quadro RTX 3000 1 év garancia
- Yurbuds Ironman fülhallgató
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest
Bar en arra is inkabb explicitebb megoldast valasztanek pl