underscore
提供如下函数,很是方便:
Underscore
提供了常用的函數。
Collections
- each
- map
- reduce
- reduceRight
- find
- filter
- where
- findWhere
- reject
- every
- some
- contains
- invoke
- pluck
- max
- min
- sortBy
- groupBy
- countBy
- shuffle
- toArray
- size
Arrays
- first
- initial
- last
- rest
- compact
- flatten
- without
- union
- intersection
- difference
- uniq
- zip
- unzip
- object
- indexOf
- lastIndexOf
- sortedIndex
- range
Functions
- bind
- bindAll
- partial
- memoize
- delay
- defer
- throttle
- debounce
- once
- after
- wrap
- compose
Objects
- keys
- values
- pairs
- invert
- functions
- extend
- pick
- omit
- defaults
- clone
- tap
- has
- isEqual
- isEmpty
- isElement
- isArray
- isObject
- isArguments
- isFunction
- isString
- isNumber
- isFinite
- isBoolean
- isDate
- isRegExp
- isNaN
- isNull
- isUnderfined
Utility
- noConflict
- identity
- times
- random
- mixin
- uniqueId
- escape
- unescape
- result
- template
Chaining
- chain
- value
Lo-Dash
建議使用Lo-Dash,性能優異很多的實現。
underscore.string
補充了underscore
缺少的對字符串的操作,不過有些其實JavaScript原生就帶了。
- capitalize
- chop
- clean
- chars
- swapCase
- count
- escapeHTML
- unescapeHTML
- insert
- isBlank
- join
- lines
- reverse
- splice
- startsWith
- endsWith
- succ
- strip
- lstrip
- rstrip
- titleize
- camelize
- classify
- underscored
- dasherize
- humanize
- trim
- ltrim
- rtrim
- truncate
- prune
- words
- sprintf
- lpad
- rpad
- lrpad
- center
- ljust
- rjust
- toNumber
- strRight
- strRightBack
- strLeft
- strLeftBack
- stripTags
- toSentence
- toSentenceSerial
- repeat
- surround
- quote
- unquote
- slugify
- naturalCmp
- toBoolean
與Lo-Dash配合使用無壓力。
其他語言
Underscore被移植到了其他語言,例如Underscore.lua和Underscore.php。
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。