Tin mới
JavaScript: Scripting language
Web APIs: Programming interfaces
Structuring content with HTML module
Dynamic scripting with JavaScript module
Using substring() with length property
The following example uses the substring() method and length property to extract the last characters of a particular string. This method may be easier to remember, given that you don't need to know the starting and endin
The difference between substring() and substr()
There are subtle differences between the substring() and substr() methods, so you should be careful not to get them confused.
Differences between substring() and slice()
The substring() and slice() methods are almost identical, but there are a couple of subtle differences between the two, especially in the way negative arguments are dealt with.
The following example replaces a substring within a string. It will replace both individual characters and substrings. The function call at the end of the example creates a string Brave New Web from the original string B
This page was last modified on Jul 10, 2025 by MDN contributors.