This file contains hidden or 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
/* | |
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); |
This file contains hidden or 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 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"); |
This file contains hidden or 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
function Apple (type) { | |
this.type = type; | |
this.color = "red"; | |
} | |
Apple.prototype.getInfo = function() { | |
return this.color + ' ' + this.type + ' apple'; | |
}; | |
var apple = new Apple('macintosh'); |
This file contains hidden or 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 elasticsearch = require('elasticsearch'); | |
var client = elasticsearch.Client({ | |
hosts: [ | |
'localhost:9200' | |
] | |
}); | |
var tk = { | |
_bulkArray: function(idx, type, data) { |
NewerOlder