JSFiddle - React, Tailwind, and code Playground

by chustedde

JavaScript

_.mixin({
  // Case-insensitive pick that returns an object with keys in the original case
	picki : function(obj, keys) {
		var copy = {};
		var objKeyList = _.keys(obj);
		
    	_.each(keys, function(key) {
    		_.each(objKeyList, function(o){
    			if (key.toString().toLowerCase() === o.toString().toLowerCase()) {
    				// o is from the list of keys extracted from the object, so
    				// it's in the original case
    				copy[o] = obj[o];
    			}
    		});
    	});
    	return copy;
	}
});
 
var stuff = {"A":"hello", "B":"world", "C":"!"};
var theKeys = ["a", "b"];
 
alert("Despite the name, I'm very picky\n" + JSON.stringify(_.pick(stuff, theKeys)));
alert("I'm not picky!\n" + JSON.stringify(_.picki(stuff, theKeys)));