.bind() on curly bracket
.bind() on curly bracket
by Nirvanachain
JavaScript
var obj = {
quantity: 100,
price: 2,
firstName: 'Jon',
lastName: 'Smith',
methods: function() {
return {
firstName: 'Mary',
lastName: 'Cooper',
total: function() {
return this.quantity * this.price;
}.bind(this),
fullName: function() {
return this.firstName + ' ' + this.lastName
}.bind(this)
}
}
};
console.log( obj.methods().total() );
console.log( obj.methods().fullName() );