📜  indexOf() 用法 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:32.445000             🧑  作者: Mango

代码示例1
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)