public
anonymous / stuff.js
Created

  • Download Gist
stuff.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
http://blog.coolaj86.com/articles/intro-to-jshint-training-wheels-for-javascript.html
http://blog.coolaj86.com/articles/how-and-why-auto-executing-function.html
https://github.com/FuturesJS/forEachAsync
https://github.com/FuturesJS/FuturesJS/tree/v2.0/join
https://github.com/FuturesJS/FuturesJS/tree/v2.0/lateral
 
(function () {
"use strict";
 
var net = require('net')
, client
;
 
client = net.connect({ port: 3030, host: "10.10.10.106" });
 
client.on('connect', function () {
console.log('client connected');
client.write('Hello\n');
 
process.stdin.resume();
});
 
client.on('data', function (chunk) {
console.log(chunk.toString('utf8'));
});
 
process.stdin.on('data', function (chunk) {
client.write(chunk);
});
 
}());
 
(function () {
"use strict";
 
var net = require('net')
, client
, host = process.argv[2] || "127.0.0.1"
, port = process.argv[3] || 3030
;
 
client = net.connect({ port: port, host: host });
 
client.on('connect', function () {
console.log('client connected');
client.write('Hello\n');
});
 
process.stdin.pipe(client);
client.pipe(process.stdin);
}());
 
undefined
var obj = { };
undefined
typeof obj;
"object"
obj;
Object {}
var arr = [ ];
undefined
typeof arr;
"object"
Array.isArray(arr);
true
Array.isArray(obj);
false
clear()
 
 
undefined
obj = { "foo": "bar" };
Object {foo: "bar"}
Object.keys(obj);
["foo"]
obj = { "foo": "bar", "baz": "corge" };
Object {foo: "bar", baz: "corge"}
obj
Object {foo: "bar", baz: "corge"}
Object.keys(obj);
["foo", "baz"]
obj = {
"foo": "bar"
, "baz": "corge"
};
Object {foo: "bar", baz: "corge"}
Object.keys(obj);
["foo", "baz"]
obj.grault;
undefined
obj.grault = "garply";
"garply"
obj
Object {foo: "bar", baz: "corge", grault: "garply"}
console.log(obj);
Object {foo: "bar", baz: "corge", grault: "garply"}
undefined
console.log(JSON.stringify(obj));
{"foo":"bar","baz":"corge","grault":"garply"}
undefined
var arr = [1, "2", "three", 4.2];
undefined
arr
[1, "2", "three", 4.2]
obj["foo"];
"bar"
obj.bar;
undefined
obj.foo;
"bar"
obj["foo"];
obj.foo;
 
"bar"
var key = "foo";
undefined
obj[key];
"bar"
function printPairs(key) {
console.log(key, obj[key]);
}
undefined
Object.keys(obj).forEach(printPairs);
foo bar
baz corge
grault garply
undefined
obj["0"] = 42;
42
Object.keys(obj).forEach(printPairs);
0 42
foo bar
baz corge
grault garply
undefined
obj[0];
42
obj.0;
SyntaxError: Unexpected number
arr
[1, "2", "three", 4.2]
arr[0]
1
Object.keys(arr).forEach(printPairs);
0 42
1 undefined
2 undefined
3 undefined
undefined
arr[1];
"2"
Object.keys(arr);
["0", "1", "2", "3"

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.