Uso de null y undefined en JavaScript

Los valores null y undefined suelen dar muchos dolores de cabeza a los programadores. En el artículo Handling null and undefined in JavaScript se explica cómo se deben usar en JavaScript:

One aspect of JavaScript development that many developers struggle with is dealing with optional values. What are the best strategies to minimize errors caused by values that could be null, undefined, or otherwise uninitialized at runtime?

Some languages have built-in affordances for those circumstances. In some statically typed languages, you can say that null and undefined are illegal values, and let your programming language throw a TypeError at compile time, but even in those languages, that can’t prevent null inputs from flowing into the program at runtime.

To get a better handle on this problem, we need to understand where these values can come from. Here are some of the most common sources:

  • User input

  • Database/network records

  • Uninitialized state

  • Functions which could return nothing

JavaScript, ese lenguaje malo malo malo

Lenguaje malo y con programadores ignorantes, según podemos leer en Quora en la siguiente respuesta a la pregunta Which commonly used programming language has the most ignorant programmers on average?:

Hands-down, it’s JavaScript. The number of really, really bad JS devs out there staggers the mind. They are responsible for the huge number of crap JS libraries, especially in the npm repositories.

They actually believe that JavaScript is sprinkled with fairy dust. They think JavaScript is somehow unique in terms of features and capabilities, when, in fact, there is absolutely nothing new nor special about this poorly designed language. Dynamic typing? Prototypes? Lambdas? Asynchronous programming? We’ve seen them all before in other languages.


I agree with Ryan Gedwill’s answer. “JavaScript is the most ignorant community because they don’t understand the word simple.”

Ataque a la web de British Airways

En Las 22 líneas de JavaScript que permitieron el robo de datos de 380.000 clientes de British Airways se comenta un poco el reciente ataque que ha sufrido la web de British Airways y que ha permitido el robo de los datos de las tarjetas bancarias de miles de clientes.

El código empleado en el robo es tan tan sencillo que parece hasta mentira que sea verdad.

Algunas páginas adicionales con más información sobre el tema: