Check typeof length instead of instanceof