0

iam new to JS so here's the question: I want to make a method to string Object. For example :

word = "Hello"
word1 = word.method() ->
word1 = "Hello123"

My method adds "123" to my str. My thoughts:

function NewStr() {
this.method = function () { return NewStr + "123"};
}
U.Alex
  • 59
  • 1
  • 7

1 Answers1

0

add method

String.prototype.NewStr= function () { return this + "123"};

Don
  • 1,334
  • 1
  • 10
  • 18