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
//In this way we prevent 2 things: | |
// 1- Polute the global scope | |
// 2- The creation of the array name each time digitToName is called | |
var digitToName = (function(digit){ | |
var names = ['one', 'two', 'tree'] | |
return function(){ | |
return names[digit]; | |
} | |
}()); |
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 oldObj = { | |
first: function() {}, | |
second: function() {} | |
}; | |
var newObj = Object.create(oldObj); | |
newObj.third = function() {}; |
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
//Syntatic sugar to add methods to any function faster | |
Function.prototype.method = function (name, func) { | |
this.prototype[name] = func; | |
return this; | |
}; | |
//Example | |
//for any class... | |
function HelloClass(){ |
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 log = Function.prototype.call.bind(console.log, console); | |
var error = Function.prototype.call.bind(console.error, console); | |
var info = Function.prototype.call.bind(console.info, console); |
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
Sublime regex for remove _id from export | |
, "_id" : \{ "\$oid" : ".*?" \} | |
Regex not greedy | |
* - zero or more | |
*? - zero or more (non-greedy) | |
+ - one or more |
NewerOlder