【发布时间】:2012-08-12 19:03:55
【问题描述】:
我正在尝试使用 underscore.js 过滤这个 javascript 对象,但我不知道为什么它不起作用,它的意思是找到任何包含“how”的问题值。
var questions = [
{question: "what is your name"},
{question: "How old are you"},
{question: "whats is your mothers name"},
{question: "where do work/or study"},
];
var match = _.filter(questions),function(words){ return words === "how"});
alert(match); // its mean to print out -> how old are you?
完整代码在这里(underscore.js 已经包含):http://jsfiddle.net/7cFbk/
【问题讨论】:
标签: javascript filter