For example, I would love to see something like this assertion idea go through. It would allow you to do something like TypeError.assert(someCondition)
. Many languages have some sort of assert function or statement. It would be nice if JavaScript does as well.
I guess someone could utilize the fact that null!
will always throw an assertion error, and with a bit of hacking, emulate assertions as follows:
function operateOnArray(array) {
Array.isArray(array) || null!
...
}
But, it would be preferable to just provide a native assert function.
function operateOnArray(array) {
TypeError.assert(Array.isArray(array))
...
}