To access a method of the object we use dot operator like nameOfObject.nameOfMethod()
. This is how I understand the dot operator.
This understanding of the dot operator is not helping me understand the syntax of promises in JavaScript. E.g see the code below:
var askMom = function () {
willIGetNewPhone // calling the promise
.then(function (fulfilled1) {
// yay, you got a new phone
console.log(fulfilled);
})
.then(function (fulfilled2) {
// yay, you got a new phone
console.log(fulfilled2);
})
.catch(function (error) {
// ops, mom don't buy it
console.log(error.message);
});
}
It appears to me as if the code is saying - nameOfObject.thenMehtod().thenMethod().catchMethod();
How do I understand this? Does it mean it's normal in JavaSript to call methods of an object by using nameOfObject.method1().method2().method3;