Skip to content

Instantly share code, notes, and snippets.

var database = [
{
"jap": "あ",
"roman": "a"
},
{
"jap": "い",
"roman": "i"
},
{
@vincentzierigen
vincentzierigen / Clean Object
Created November 16, 2015 16:50
Deletes all empty keys from an Object
/*
* Clean Object
* Cleans object from keys are not being used
* @param {Object} dirty
* @returns {Object} clean
*/
function cleanObject(object) {
var keys = Object.keys(object);
keys.map(function(obj, i) {
var value = object[obj];
//Tells if a value is numeric or not
function isNumeric(num){
return !isNaN(num)
}
@vincentzierigen
vincentzierigen / Trim Object
Last active August 29, 2015 14:20
Trims every string of an object, at any level (inside Arrays or even inside other objects)
/*
* Trim Object
* Trims all strings in all levels
* @param {Object} dirty
* @returns {Object} clean
*/
function trimObject(object){
if(typeof object === 'string'){
object = object.trim().replace(/\t/g,'').replace(/\n/g,'');
}else if(object instanceof Array){