当前位置: 首页 > 文档资料 > Lazy.js 英文文档 >

functions

优质
小牛编辑
134浏览
2023-12-01

Creates a Sequence consisting of the keys from this sequence whose values are functions.

Signature

ObjectLikeSequence.functions = function() { /*...*/ }
ObjectLikeSequence.functions = function functions() {
  return this
.filter(function(v, k) { return typeof(v) === "function"; })
.map(function(v, k) { return k; });
}
NameType(s)Description
returnsSequence

The new sequence.

Examples

var dog = {
  name: "Fido",
  breed: "Golden Retriever",
  bark: function() { console.log("Woof!"); },
  wagTail: function() { console.log("TODO: implement robotic dog interface"); }
};

Lazy(dog).functions() // sequence: ["bark", "wagTail"]