Home > Article > Web Front-end > How to override padleft method in js
Please look at the code below
//重写padleft方法 String.prototype.PadLeft = function (len, charStr) { var s = this + ''; return new Array(len - s.length + 1).join(charStr) + s; }
##The above is what I compiled for everyone to rewrite padleft in js Method, I hope it will be helpful to everyone in the future. Related articles:
What are the inheritance methods in js
How to pass two in JS onclick Specific steps for giving parameters to JS methods
In-depth explanation of js overwriting original methods and providing rewriting methods
The above is the detailed content of How to override padleft method in js. For more information, please follow other related articles on the PHP Chinese website!