📅  最后修改于: 2022-03-11 15:02:32.445000             🧑  作者: Mango
function find(needle, haystack) {
var results = [];
var idx = haystack.indexOf(needle);
while (idx != -1) {
results.push(idx);
idx = haystack.indexOf(needle, idx + 1);
}
return results;
}
Code language: JavaScript (javascript)