|
My first try at prototype, so don't make me feel bad <script type="text/javascript">
var string = "Hello World!"
String.prototype.reverse = function(){ for( a = this.length ; a > -1 ; a -- ){ var New = this.charAt(a); document.write(New); } } string.reverse()
</script>
|
|
|
|
BEtter then I can do Crazy. Also, I don't see where this would be used, but it could be fun to mess with.
|
|
|
|
|
BEtter then I can do Crazy. Also, I don't see where this would be used, but it could be fun to mess with. It's open source so..people can um..study it
|
|
|
|
Here's another way to do it.
<script type="text/javascript">
var nMessage = ''; var Container = []; String.prototype.strReverse = function() { for( z = 0 ; z < this.length ; z ++ ) Container.push( this[z] ); Container.reverse(); for( x = 0 ; x < Container.length ; x ++ ) nMessage += Container[x] return nMessage; }
var Message = "Hello World!"; document.write( Message.strReverse() );
</script>
|
|
|
|
String.prototype.strReverse = function() { var nMessage = ''; var Container = []; for( z = 0 ; z < this.length ; z ++ ) Container.push( this[z] ); Container.reverse(); for( x = 0 ; x < Container.length ; x ++ ) nMessage += Container[x] return nMessage; }
var Message = "Hello World!"; document.write( Message.strReverse() );
That'd probably be more effective, because if you used it twice, it may give an error in some browsers (thought it shouldn't, because you're using them in functions)
|
|
|
|