iT邦幫忙

2018 iT 邦幫忙鐵人賽
DAY 12
0
Modern Web

一個 JS 學習者的日常系列 第 12

一個 JS 學習者的日常 day11

【玩玩小東西】
今天來實作一個把語法串起來的函式,例如以下

$(Jim).breakTheIce("Hi!").introduce()

JS Bin

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()

上一篇
一個 JS 學習者的日常 day10
下一篇
一個 JS 學習者的日常 day12
系列文
一個 JS 學習者的日常30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言