我正在尝试创建一个human以三个方法命名的 JavaScript 对象walk,eat并且talk我想这样调用它(没有方法应该打印任何值)human.talk('hello').walk('home').eat('pizza'):。
我有这个代码:
var human = {
talk : function talk(t){
},
walk : function walk(w){
},
eat : function eat(e){
}
};
console.log(human.talk('hello').walk('home').eat('pizza'));
但我收到Uncaught TypeError: Cannot call method 'walk' of undefined
为什么??