Typescript Empty Array Length Javascript Method Vs Function