 |
|
 |
| |
Developer on focus
Anton Zamov is a dipl. engineer with more than 6 years of active professional
experience and many awards ...
read more>>
|
|
 |
 |
 |
|
 |
|
 |
| |
|
How to define a function that extends the capabilities of String objects?
|
<HTML>
<HEAD>
</HEAD>
<BODY>
<SCRIPT>
// Define a function that extends the capabilities of String objects
function reverse()
{
myArray = new Array(this.length);
for(myEnum=0; myEnum<this.length; myEnum++)
{
myArray[myEnum] = this.substr(myEnum,1)
}
myArray.reverse();
return myArray.join("");
}
// Register the new function
String.prototype.reverse = reverse;
// Create a string object and test the String.reverse() method
myString = new String("ABCDEFGH");
document.write(myString.reverse())
document.write("<BR>")
</SCRIPT>
</BODY>
</HTML>
|
About the author of this programming example or tutorial:
Anton Zamov is a software engineer with more than6 years
of active experience in web and software development and design.
Anton Zamov has extensive experience and broad knowledgebase
in C# and JAVA programming and has created a lot of
running e-commerce systems, portals and content management
systems using PHP and other web development technologies.
For more information about Anton Zamov, you may visit the personal web site of
Anton Zamov.
|
|
|
 |
 |
 |
|
|