Varma Ramgoolam
Varma Ramgoolam

Reputation: 13

The string.prefix() operator, does it exist?

 'string0'.Prefix('string1') === 'string2'

I have come across a prefix operator but i cant find any documentation on how to use it anywhere on the web - it all gets covered by prefix and suffix operators

Does someone know about it?

Does it even exist?

Upvotes: 1

Views: 1436

Answers (1)

jeanfrg
jeanfrg

Reputation: 2351

Someone probably create something like the following in the code you're checking out.

String.prototype.Prefix = function(anotherStr) {
  return anotherStr + this;
}

var name = "Jean";
var sentence = "Hi there, ";

alert(name.Prefix(sentence));

Checkout this link for more information on prototypes in javascript

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/prototype

Note: Keep in mind, extending native types is not considered best practice

Upvotes: 1

Related Questions