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
| let testObj = { | |
| name: "Fernando", | |
| age: 35, | |
| speak: function() { | |
| console.log("Hello world!") | |
| }, | |
| address: undefined | |
| } | |
| let serializedObj = JSON.stringify(testObj) | |
| testObj.speak() |
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
| let testObj = { | |
| name: "Fernando", | |
| age: 35, | |
| speak: function() { | |
| console.log("Hello world!") | |
| }, | |
| toJSON: function() { | |
| console.log("toJSON called") | |
| }, | |
| address: undefined |
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
| const serialize = require("node-serialize") | |
| var obj = { | |
| name: 'Bob', | |
| say: function() { | |
| return 'hi ' + this.name; | |
| } | |
| }; | |
| var objS = serialize.serialize(obj); | |
| console.log(typeof objS === 'string'); |
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 fileSystem = require( "fs" ); | |
| var JSONStream = require( "JSONStream" ); | |
| var books = [ | |
| {name: "The Philosopher's Stone", year: 1997}, | |
| {name: "The Chamber of Secrets", year: 1998}, | |
| {name: "The Prisoner of Azkaban", year: 1999}, | |
| {name: "The Goblet of Fire", year:2000}, | |
| {name: "The Order of the Phoenix", year:2003}, | |
| {name: "The Half-Blood Prince", year:2005}, | |
| {name: "The Deathly Hallows", year:2007} |
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
| process.argv.forEach( (val, index) => { | |
| console.log(index + ': ' + val); | |
| }); |
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
| let args = process.argv.slice(2); | |
| args.forEach( (val, index) => { | |
| console.log(index + ': ' + val); | |
| }); |
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
| class Obj { | |
| constructor() { | |
| this.a = 1 | |
| this.b = 1 | |
| this.c = 1 | |
| } | |
| method(st){ | |
| } | |
| } |
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
| let obj = { | |
| a: 1, | |
| b: 2, | |
| test: function() { return 0} | |
| } | |
| for(m in obj) { | |
| console.log(m) | |
| } | |
| console.log(Object.keys(obj)) |
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 asyncLoop(list, callback) { | |
| let results = [] | |
| list.forEach( fn => { | |
| fn( (err, result) => { | |
| if(err) return callback(err) | |
| results.push(result) | |
| if(results.length == list.length) { | |
| callback(null, results) | |
| } | |
| }) |
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
| const req = require("request") | |
| let calls = [ | |
| function (cb) { | |
| req.get('http://www.google.com', cb) | |
| }, | |
| function (cb) { | |
| req.get('http://www.yahoo.com', cb) | |
| }, | |
| function (cb) { | |
| req.get('http://www.msdn.com', cb) |