Get the App
SLTechnology News&Howtos  ›  Development  › 

How JavaScript masks strings

Shulou Source: shulou.com Published: 2022-06-01 05:04:20 11月14日 Update

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!

Tags: Characters strings masking content articles learning help code location just password time easy to understand more end organization for example knowledge tape industry Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Redmi OPPO Reno Shulou Tech Info Apple