Implementing the flat function by my own, also a function that removes empty fields from arrays.
This commit is contained in:
Kevin Röbert
2019-03-27 18:31:37 +01:00
parent f69ae79adb
commit 869cd63e64
3 changed files with 17 additions and 3 deletions

View File

@@ -21,6 +21,20 @@
* This script is responsible for some tools.
*/
/*
* To support Waterfox.
*/
Array.prototype.rmEmpty = function() {
return this.filter(v => v);
};
/*
* To support Waterfox.
*/
Array.prototype.flatten = function() {
return this.reduce((a, b) => a.concat(b), []);
};
/**
* Check if an object is empty.
* @param {Object} obj