How JavaScript masks strings
This article mainly shows you "JavaScript how to mask strings", the content is easy to understand, clear, hope to help you solve doubts, the following let the editor lead you to study and learn "JavaScript how to mask strings" this article.
Masking string
Sometimes we need to mask part of the string, not just with passwords. The following code gets the part of the string through substr (- 3), that is, the first three characters from the end of the string, and then fill the remaining positions with your favorite characters (for example, with *)
Const password = "hackme"; password.substr (- 3) .padStart (password.length, "*"); / / * kme is all the content of the article "how JavaScript masks strings". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!