是否有一个 JavaScript 库包含一组丰富的非常高级的常用函数?
我发现大多数知名的 javascript 库(例如 jquery、YUI...等)都缺少许多高级函数。以字符串操作为例,startsWith、endsWith、contains、lTrim、rTrim、trim、isNullOrEmpty...等。这些功能其实都是很常见的。
我想知道是否存在一个 javascript 库/ javascript 库插件可以填补这些空白(包括但不限于字符串操作)?
如果库不重写原型那就太好了。
I find that many high level functions are missing in most well-known javascript libraries such as jquery, YUI...etc. Taking string manipulation as an example, startsWith, endsWith, contains, lTrim, rTrim, trim, isNullOrEmpty...etc. These function are actually very common ones.
I would like to know if there exists a javascript library/ plugin of a javascript library that fills these gaps (including but not limited to string manipulation)?
It would be great if the library does not override the prototype.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
看看 underscore.js (遗憾的是,没有字符串操作,但有很多其他好东西)。
Take a look at underscore.js (sadly, no string manipulation, but lots of other good stuff).
大多数字符串函数都可以使用与字符串对象关联的其他方法来使用,例如,
如果您愿意,您可以将这些函数包装到其他函数中。我认为向字符串对象添加原型将是到达那里的方法,并且您找到的任何库都可能会沿着这条路线走下去。
Most of those string functions are available using other methods associated with the string object eg
You could wrap these functions up into other functions if you wish. I think adding prototypes to the string object would be the way to go there and any libraries you find will probably go down that route anyway.
ms ajax core 库包含所有这些字符串方法以及日期方法等基本上是将 .net 引入 js 的勇敢尝试。
您不需要加载整个 MS Ajax js 堆栈,只需加载核心文件。
The ms ajax core library contains all of those string methods as well as date methods etc. basically a valiant attempt at bringing .net to js.
You don't need to load the entire MS Ajax js stack, just the core file.
如果您不想扩展原型,所有这些都可以使用包装器轻松实现。
函数仅创建一次,因此非常高效。但是在辅助对象上使用包装器确实会产生一次额外的函数调用。
All of this is easily implemented with wrappers if you don't want to extend the prototype
The functions are only being created once, so its quite efficient. But using a wrapper over a helper object does incur one extra function call.
underscore.string 看起来可能适合您的需求。他们是这样描述的:
underscore.string looks like it might suit your needs. Here's how they describe it: