Execute two functions sequentially in JavaScript

Let's assume that you want to declare a function inside another function so that you can call them sequentially as a().b().

Example:

javascript
let erik = () => {

    let fn = {}

    fn.age = () => 31
    fn.loc = () => 'Barcelona'

    return fn

}

Then:

javascript
erik().age() // 31
erik().loc() // 'Barcelona'

Hi, I'm Erik, an engineer from Barcelona. If you like the post or have any comments, say hi.