The code you showed correctly extends the String prototype. However, you are trying to call a method for a function with String.testthing , not a String instance.
alert("".testthing());
If you really want to call methods from the String construct, you need to extend the prototype to Function
Function.prototype.testthing = function () { return "working"; } alert(String.testthing());
source share