Object 文字和方法分组

Object literal and method grouping

谁能告诉我如何以 "object-literal" 的方式写下面的内容..

my.item('apple').suffix("is awesome")
// console.log >> apple is awesome

我的尝试……但是显然不行。

var my = {
    item:function(item){
        my.item.suffix = function(suffix){
            console.log(item, suffix);
        }
    }
};

(如果标题有误,抱歉。我不确定术语)

试试这个:

var my = {
  thing: undefined,

  // sets the `thing` property of `my`,
  // then returns `my` for chaining
  item: function (t) {
    thing = t;
    return this;
  },

  // concatenates the `thing` property with the given
  // suffix and returns it as a string
  suffix: function (s) {
    return thing + ' ' + s;
  }
};

my.item('apple').suffix("is awesome");
//--> apple is awesome