null
Null all of the things! This package was originally created as a joke, but hey now it actually does something non-trivial.
If you ever use null
for logic tests, you can try using a Symbol
instead via the NullRef library provided by this package.
This package provides for a NULL
constant that is a Symbol from the Global Symbol Registry, as well as convenience methods for testing, casting, and comparing values.
Usage
Require and reference what you need:
const nullref = ; // note that the variable name should not be null, here we use nullrefconst nulltest = nullreflib; // load the full library of convenience features const isNull = nullrefisNull // or just load the main ones you want (checks for null or NULL)const isNullRef = nullrefisNullRef // checks for NULL only const NULL = ; // NULL symbol instance (singleton);
Consume and use as needed.
let x = null; //returns true if x is null or NULLif nulltest //do somethingif // same as above //cast a variable to NULL if it is null or NULL, otherwise it returns itselfif NULL === nulltest // do something