Javascript String reverseThisIsh()

Description

Javascript String reverseThisIsh()


//Just like you can add methods to your own constructor, you can also add methods and properties to built in classes in JavaScript like Arrays and Objects.

//Add a reverse method to the String 'class' so that every instance of String can call reverse and reverse itself.
  
  //code here// w  ww . ja v  a  2  s  . c o  m
String.prototype.reverseThisIsh = function() {
  console.log(this.split('').reverse().join(''));  
};
var testString = "try this on for size";
testString.reverseThisIsh();



PreviousNext

Related