【玩玩小東西】
今天來實作一個把語法串起來的函式,例如以下
$(Jim).breakTheIce("Hi!").introduce()
var $ = function (Person) {
return {
breakTheIce: function (message) {
console.log( message + " My name is " + Person.name);
return this;
},
introduce: function () {
console.log("I'm a " + Person.intro + " Do you want to program with me?");
return this;
}
}
}
var Jim = {
name: "Jim Hu",
intro: "Progammer!"
}
$(Jim).breakTheIce("Hi!").introduce()