• Web Hosting
  • Reseller
  • ¿Por qué elegirnos?
  • Ayuda
  • Mi cuenta
  • COMENZAR

PHP's empty en JavaScript

Web Hosting - Dominios - Reseller

function empty (mixedVar) {
// example 1: empty(null)
// returns 1: true
// example 2: empty(undefined)
// returns 2: true
// example 3: empty([])
// returns 3: true
// example 4: empty({})
// returns 4: true
// example 5: empty({'aFunc' : function () { alert('humpty'); } })
// returns 5: false
 
var undef
var key
var i
var len
var emptyValues = [undef, null, false, 0, '', '0']
 
for (i = 0, len = emptyValues.length; i < len; i++) {
if (mixedVar === emptyValues[i]) {
return true
}
}
 
if (typeof mixedVar === 'object') {
for (key in mixedVar) {
if (mixedVar.hasOwnProperty(key)) {
return false
}
}
return true
}
 
return false
}
Leer también

Función para validad e-mail (Vistas: 385)

¿Preguntas?

Escribinos tus inquietudes y en pocos minutos un asesor se estará comunicando con usted para ayudarlo.

Medios de pago

Los valores mencionados en el sitio son DOLARES ESTADOUNIDENSE (USD) y contratando anualmente en cualquier plan tiene 2 (dos) meses de descuento.

Enlaces

  • Hosting Wordpress
  • Hosting Joomla
  • Hosting Drupal
  • Hosting Ruby (ROR)
  • Hosting Inmobiliarias
  • Migramos tu Sitio
  • Game Server
  • Nuestros DNS

| Teléfonos

+54 11 30078351
+54 11 67016691

Seguinos