This article describes how to use JavaScript to determine whether the prefix and suffix are spaces. it involves the regular expression replacement, judgment, and attribute operation techniques of javascript character strings, for more information about how to determine the prefix and suffix of JavaScript, see the example in this article. Share it with you for your reference. The details are as follows:
// Js judge the suffix String. prototype. endsWith = function (suffix) {return this. indexOf (suffix, this. length-suffix. length )! =-1 ;}; // Js determines the prefix if (typeof String. prototype. startsWith! = 'Function') {// see below for better implementation! String. prototype. startsWith = function (str) {return this. indexOf (str) = 0 ;};}// Js empty (including all spaces) String. prototype. isNullEmptyOrSpace = function () {if (this = null) return true; return this. replace (/s/g ,''). length = 0 ;};
I hope this article will help you design javascript programs.