If the duration object truly has a method named getDays(), then it will be called without the error. You may be misinterpreting how to use the API.
All objects are of type 'object'. JavaScript is not
Java and there are no true object types in the way that we think about them in Java. They're just fancily decorated instances of Object.