Last active
August 29, 2015 14:14
-
-
Save AbeEstrada/51c20bda13ef11f94757 to your computer and use it in GitHub Desktop.
dubizzle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var foo = function() { | |
this._values = {}; | |
this.set = function(key, value) { | |
this._values[key] = value; | |
}; | |
this.get = function(key) { | |
return this._values[key]; | |
}; | |
}; | |
var instance = new foo(); | |
instance.set('key', 'value'); | |
console.log(instance.get('key')); | |
instance.key; | |
var instance2 = new foo(); | |
instance2.set('key', 'value2'); | |
console.log(instance2.get('key')); | |
instance2.key; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var paths = [ | |
{ name: 'icon', type: 'jpeg', path: '../' }, | |
{ name: 'badge', type: 'gif', path: '../' }, | |
{ name: 'pattern', type: 'jpeg', path: '../' }, | |
{ name: 'boy', type: 'png', path: '../' }, | |
{ name: 'logo', type: 'gif', path: '../' }, | |
{ name: 'bg', type: 'jpeg', path: '../' }, | |
{ name: 'something', type: 'gif', path: '../' }, | |
{ name: 'button', type: 'png', path: '../ ' } | |
]; | |
var sortPaths = function(paths) { | |
var o = {}; | |
for (var i = 0; i < paths.length; i++) { | |
var path = paths[i]; | |
if (path.type in o === false) { | |
o[path.type] = []; | |
} | |
o[path.type].push(path.path+path.name+'.'+path.type); | |
}; | |
return o; | |
}; | |
var sortedPaths = sortPaths(paths); | |
console.log(sortedPaths); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment