This might be very basic but I am not able to understand how chaining and return works at the same time like for example
let array = [1, 2, 3]
let newArray = array.map(val => val * 10).map(val => val * 10)
console.log(newArray) // [100, 200, 300]
Here we can keep on adding .map and it will keep returning a new array. It behaves like when chaining stops it knows now that it has to return value but when chaining continues it keeps treating it as object. How does that work and how can I achieve similar functionality in my code.