Understanding JavaScript substring():
The JavaScript substring() method is a powerful tool for extracting parts of a
string. However, its behavior can sometimes be confusing for beginners. This
article will help you understand how substring() works, its quirks, and common
mistakes you should avoid.
What is the substring() Method?
The substring() method in JavaScript extracts a portion of a
string and returns it as a new string without modifying the original string.
It takes two arguments:
# Start index: The position where
the extraction begins (inclusive).
# End index: The position where
the extraction ends (exclusive).
string.substring(startIndex, endIndex)
If the
endIndex is omitted, the method extracts the rest of the string
starting from startIndex.
Example Usage
Let’s look at some basic examples:
let x = "Learn" console.log(x.substring(5, 1)) console.log("kumaratuljaiswal.in");
Disclaimer
All tutorials are for informational and educational purposes only and have been made using our own routers, servers, websites and other vulnerable free resources. we do not contain any illegal activity. We believe that ethical hacking, information security and cyber security should be familiar subjects to anyone using digital information and computers. Hacking Truth is against misuse of the information and we strongly suggest against it. Please regard the word hacking as ethical hacking or penetration testing every time this word is used. We do not promote, encourage, support or excite any illegal activity or hacking.
0 comments:
Post a Comment
For Any Tech Updates, Hacking News, Internet, Computer, Technology and related to IT Field Articles Follow Our Blog.