Hacker News new | ask | show | jobs
by arcatek 4053 days ago
the String function is also a nice way to cast a value to a string (using .toString() is unsafe because it may not exist, such as with undefined and null): String(42) === "42".

An other thing that could maybe be covered is this specifity:

    typeof "42" === "string"
    typeof String(42) === "string"
    typeof new String(42) === "object"
Native constructors are ... fun beasts, to say the least.