Is there a way to extend a method to the String prototype and manipulate the string value?
I'm facing some difficulty in accessing the actual string value, as this
, the current object context, seems to refer to the string object instead.
String.prototype.test = function() { console.log(this)}
function () { console.log(this) }
'lol'.test()
VM192:2 String {0: "l", 1: "o", 2: "l", length: 3,
has: function, contains: function,
escapeRegExp: function, camelize: function…
}
How can I access the string value itself rather than just the string object?