我正在尝试使用 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/