web/data/cubicweb.js
changeset 7284 a474cb989546
parent 6448 8590d82e9b1b
child 7649 ede740bd7077
--- a/web/data/cubicweb.js	Fri Apr 29 12:12:49 2011 +0200
+++ b/web/data/cubicweb.js	Fri Apr 29 12:34:53 2011 +0200
@@ -308,6 +308,17 @@
     },
 
     /**
+     * returns the last element of an array-like object or undefined if empty
+     */
+    lastOf: function(array) {
+        if (array.length) {
+            return array[array.length-1];
+        } else {
+            return undefined;
+        }
+    },
+
+    /**
      * .. function:: difference(lst1, lst2)
      *
      * returns a list containing all elements in `lst1` that are not