var arr1 = [ {foo:1, bar:2},
{foo:3, bar:4},
{foo:5} ]
\
function foo(bar) { | |
return bar === baz? 'hello' | |
: bar === quux? 'hey' | |
: /*otherwise*/ 'hi' | |
} |
#include <stdio.h> | |
#include "xorlist.h" | |
int main(void) { | |
struct Node *list = NULL; | |
for (int i=1; i<=15; i++) { | |
push(i, &list); | |
} |
JS: The Hip Parts. | |
Chapters = | |
[ Comma-First is Comma Right | |
, !function Expressions! | |
, <!--Comments with Style--> | |
, Blow it Out Your Semi-Colon ] |
local Base = require('library').Base | |
local Person = Base { | |
-- missing properties: name | |
speak = function (self) | |
return "Hello, I am " .. self.name | |
end | |
} | |
local Programmer = Person { |
js> function inspect(obj) {var res = []; for (var k in obj) res.push([k, typeof (o = obj[k]) == 'boolean' ? o : typeof o].join(":")); return "{ " + res.join(", ") + " }"} | |
js> print(Object.getOwnPropertyNames(this).map(function(n) {return [n, inspect(Object.getOwnPropertyDescriptor(this, n))].join(Array(24-n.length).join(" "))}).join("\n")) | |
Function { value:function, writable:true, enumerable:false, configurable:true } | |
Object { value:function, writable:true, enumerable:false, configurable:true } | |
eval { value:function, writable:true, enumerable:false, configurable:true } | |
PerfMeasurement { value:function, writable:true, enumerable:false, configurable:true } | |
version { value:function, writable:true, enumerable:false, configurable:true } | |
revertVersion { value:function, writable:true, enumerable:false, configurable:true } | |
options { value:function, writable:true, enumerable:false, configurable:true } | |
load { |
function a(a1, callback) { | |
// ...does stuff | |
callback("a", "b", "c") | |
} |
// Split colon-separated parts, unescaping (but not splitting on) any \: | |
function split(str) { | |
return str.match(/(?:\\:|[^:])+/g).map(function(part) { | |
return part.replace(/\\:/g, ':') | |
}); | |
} | |
// Eg. |
var __objectInheritanceCalculated = []; | |
while((function() | |
{ | |
/* There is a object class that has not been processed */ | |
var __t = 0; | |
for (var m in objectclasses) { __t++; } | |
if (__t <= __objectInheritanceCalculated.length) return false; | |
return true; | |
})()) | |
{ |
//-- Definition | |
Function.prototype.compose = function (/* ...args */) { | |
var args = Array.prototype.slice.call(arguments) | |
, funs = [ this ].concat(args) | |
return function (/* ... */) { | |
return funs.reduceRight(function (args, f) { | |
return [ f.apply(null, args) ] | |
}, arguments)[0] | |
} |