If I have a javascript class which cannot be instantiated what should the constructor return that I can test for. The constructor always returns an object so I cannot return nul
My first approach:
My second approach:
null
doesn't work anyway)I have never designed a constructor (something invoked as the target of new
) to return anything except an object of the "expected" type.
Fail fast, avoid being too clever, and save time debugging hard-to-find bugs.
Happy coding.