【发布时间】:2018-12-29 23:16:37
【问题描述】:
如何在 HTML 表格中使用 String.prototype.startsWith 过滤器
这是我的项目使用 json 的示例,但我必须在我的项目中使用过滤器数组。
http://jsfiddle.net/8kkg3/3471/
这是我想在表格中使用的过滤器代码。
if (typeof String.prototype.startsWith != 'function') {
String.prototype.startsWith = function (str) {
return this.substring(0, str.length) === str;
}
};
const str ='John';
let result =str.startsWith('j');
console.log(result);
【问题讨论】:
-
J不是j。尝试先拨打toLowerCase
标签: javascript arrays html filter