Library with useful prototype functions

I was wondering if there is any nice library out there which contains useful functions for Strings, Arrays etc., preferably through prototype. For myself, I coded the following trivial yet commonly needed functions: String.prototype.contains = function(value) { return this.indexOf(value) > -1; } String.prototype.amount = function(value) { return this.split(value).length - 1; } However, it gets dirty if I need to have to assemble all such functions each time I come across or need such a function. So, is there any library with this kind of basic and useful functions for Strings etc.? Thanks.
i believe it would be tough to assemble functions as people add them on need basis and then the standard comes along (ECMAScript 5) and addresses some more. Whenever you right such code, its better to check if the standard started providing such a function, so that we use the standard's function than user defined. Once such requirement of mine is to find if an Object[Array Object] is empty in JS.

以上就是Library with useful prototype functions的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准