Objects can contain functions (methods):
let calculator = {
add(a, b) {
return a + b
},
subtract(a, b) {
return a - b
}
}
console.log(calculator.add(5, 3)) // 8
console.log(calculator.subtract(5, 3)) // 2
The shorthand add(a, b) {} is cleaner than add: function(a, b) {}.