- MongoDB
- ElasticSearch
- Redis
- ExpressJs
- Mongoose
var elasticsearch = require('elasticsearch'); | |
var client = elasticsearch.Client({ | |
hosts: [ | |
'localhost:9200' | |
] | |
}); | |
var tk = { | |
_bulkArray: function(idx, type, data) { |
function Apple (type) { | |
this.type = type; | |
this.color = "red"; | |
} | |
Apple.prototype.getInfo = function() { | |
return this.color + ' ' + this.type + ' apple'; | |
}; | |
var apple = new Apple('macintosh'); |
var test = function(key, value) { | |
a = {foo:{bar:{baz:"placeholder"}}}; | |
a.foo.bar.baz = {}; //creating a new object as `baz` value then assign | |
a.foo.bar.baz[key] = value; | |
console.log(JSON.stringify(a)); | |
}; | |
test("Jon", "Dough"); |
/* | |
typeof is a construct that "returns" the primitive type of whatever you pass it. | |
instanceof tests to see if the right operand appears anywhere in the prototype chain of the left. | |
*/ | |
var test = require('tape'); | |
test('typeof vs instanceof tests', function (t) { | |
t.plan(13); |
test = require('tape'); | |
// Basic module with closure | |
var Module = (function () { | |
var my = {}, | |
privateVariable = 1; | |
function setPrivateMethod(val) { | |
privateVariable = val; |
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); | |
}; |
var arr = [1,2,3,4]; | |
var res= arr.join(' '); |
npm view module_name versions |
window.onload = function() { | |
doSomethingElse(); | |
}; |