Skip to content

Instantly share code, notes, and snippets.

@jamc92
Created March 15, 2015 19:40
Show Gist options
  • Save jamc92/6f51764ec35830d61050 to your computer and use it in GitHub Desktop.
Save jamc92/6f51764ec35830d61050 to your computer and use it in GitHub Desktop.
JS - Inheritance with functions
<!DOCTYPE html>
<html>
<head>
<title>Inheritance from a build Function in JS</title>
<script type="text/javascript">
String.prototype.reverse = function() {
var salida = "";
for (var i = this.length-1; i >= 0; i--) {
salida += this.substr(i, 1);
}
return salida;
}
</script>
</head>
<body>
<script type="text/javascript">
var enString = prompt("Introduce your reverse text: ");
document.write(enString.reverse());
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment