; Programming Journey - Minish theme

Hello, I'm Alex & i write software

Cast null to String

In Programming, Nodejs, Javascript, asdsd,

Trying to use null.toString() or var.toString() to cast null type to string will throw following error:

TypeError: Cannot call method 'toString' of null

Instead of using toString() is safer to always use String(var) which returns 'null', this trick also works whit undefined using String(undefined)/String(var).

Happy Coding.

Comments

This is the begging of this adventure

In Genesis,

Here i will try to write useful stuff about programming, to keep my a history of thing i have learned over time, is intended to be a personal journal but might be useful to someone else.

Alejandro.

Comments