Home > Web Front-end > JS Tutorial > body text

How to override padleft method in js

亚连
Release: 2018-05-17 10:32:34
Original
2807 people have browsed it

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;
        }
Copy after login

##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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template