- MongoDB
- ElasticSearch
- Redis
- ExpressJs
- Mongoose
/* | |
* Helper to get a querystring value. | |
*/ | |
function getParameterByName( name ){ | |
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); | |
var regexS = "[\\?&]"+name+"=([^&#]*)"; | |
var regex = new RegExp( regexS ); | |
var results = regex.exec( window.location.href ); | |
if( results == null ) | |
return ""; |
var person = { | |
name: "James Smith", | |
hello: function(thing) { | |
console.log(this.name + " says hello " + thing); | |
} | |
} | |
person.hello.call(person, "world"); // output: "James Smith says hello world" |
function personContainer() { | |
var person = { | |
name: "James Smith", | |
hello: function() { | |
console.log(this.name + " says hello " + arguments[1]); | |
} | |
} | |
person.hello.apply(person, arguments); | |
} | |
personContainer("world", "mars"); // output: "James Smith says hello mars", note: arguments[0] = "world" , arguments[1] = "mars" |
var person = { | |
name: "James Smith", | |
hello: function(thing) { | |
console.log(this.name + " says hello " + thing); | |
} | |
} | |
var helloFunc = person.hello.bind(person); | |
helloFunc("world"); // output: "James Smith says hello world" |
window.onload = function() { | |
doSomethingElse(); | |
}; |
npm view module_name versions |
var arr = [1,2,3,4]; | |
var res= arr.join(' '); |
test = require("tape"); | |
function addMethod(object, name, fn){ | |
object._store = object._store || {}; | |
object._store[name] = object._store[name] || {}; | |
object._store[name][fn.length] = fn; | |
object[name] = function() { | |
if(this._store[name][arguments.length]) | |
return this._store[name][arguments.length].apply(this, arguments); | |
}; |
test = require('tape'); | |
// Basic module with closure | |
var Module = (function () { | |
var my = {}, | |
privateVariable = 1; | |
function setPrivateMethod(val) { | |
privateVariable = val; |