Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in /home/bateeqjg/public_html/news/wp-content/plugins/wp-syntax/wp-syntax.php on line 380
Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in /home/bateeqjg/public_html/news/wp-content/plugins/wp-syntax/wp-syntax.php on line 380
Warning: Undefined array key "layout" in /home/bateeqjg/public_html/news/wp-content/plugins/wp-about-author/wp-about-author.php on line 94
Inspired from Removing duplicate objects with Underscore for Javascript
Source:
/** @function _.uniqObjects @require Underscore.js and json.stringify @purpose return an array of objects without duplicated objects. */ _.uniqObjects = function( arr ){ return _.uniq( _.collect( arr, function( x ){ return JSON.stringify( x ); })); }; |
Example:
var foo = [ { "a" : "1" }, { "b" : "2" }, { "a" : "1" } ]; _.uniqObject( foo ); // returns [ { "a" : "1" }, { "b" : "2" } ] |