Prototype Javascript Framework

easing the pain of dynamic web applications

  • Download
  • API Docs
  • Tips and Tutorials
  • Blog
  • Discuss
  • Contribute

Array

  • clear
  • clone
  • compact
  • each
  • first
  • flatten
  • from
  • indexOf
  • inspect
  • last
  • reduce
  • reverse
  • size
  • toArray
  • toJSON
  • uniq
  • without

API Docs

  • Utility Methods
  • Ajax
  • Array
  • Class
  • Date
  • Element
  • Element.Methods
  • Element.Methods.Simulated
  • Enumerable
  • Event
  • Form
  • Form.Element
  • Function
  • Hash
  • Insertion
  • Number
  • Object
  • ObjectRange
  • PeriodicalExecuter
  • Position
  • Prototype
  • String
  • Template
  • TimedObserver
  • document
  • document.viewport
  • Learn more about Prototype »

compact

compact() -> newArray

Returns a new version of the array, without any null/undefined values.

Example

['frank', , 'sue', , 'sally', null].compact()
// -> ['frank', 'sue', 'sally']
© 2006-2007 Prototype Core Team | Licenses: MIT (source code) and CC BY-SA (documentation). mephisto-badge-tiny