Array Overrides

This is an archived post from the ExtJS era — the code may be obsolete, but the principles often still apply.

Code in this post can be obsolete, however, principles and theory may still apply.

On the way of development of my project I came to need to have set methods for javascript Array object especially intersection. Googling has shown up some but they were not LGPL, the licence what I need, so I've written them. The following override contains:

  • Ext message box input type configuration
  • Conditional Ext.overrideIf
  • New Array methods:
    • copy - one dimensional copy method
    • indexOf - index of a value within the array. New browsers may already implement this method, therefore conditional override.
    • lastIndexOf - last index of a value within the array. May be already implemented by browser too.
    • intersect - returns intersection of arrays, for example: [1,3,5,7].intersect([2,3,8,7,5]) returns [3,5,7]
    • union - returns union of arrays, for example: [1,3,5,7].union([2,3,8,7,5]) returns [1,2,3,5,7,8]
    • unique - removes duplicate values from the array and returns result as new array
  • Ext.ux.clone - deep object or array cloning function

Overrides code:

2 comments

  1. LucianApril 18, 2008archive
    Do you also have a String overrider?...
  2. jsakalosApril 18, 2008archive
    Not yet, I didn't need any so far.

Comments are closed on archived posts.