📜  javascript string startswith - Javascript 代码示例

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

代码示例6
if (!String.prototype.startsWith) {
    Object.defineProperty(String.prototype, 'startsWith', {
        value: function(search, rawPos) {
            var pos = rawPos > 0 ? rawPos|0 : 0;
            return this.substring(pos, pos + search.length) === search;
        }
    });
}