JavaScript mixin patterns
Four different ways JavaScript variables and closures can be used to implement different mix-in patterns.
Each implementation creates a mixin that creates property getter functions for model objects.
By model object I mean a function that takes properties (keys and values)( and returns an object that:
m1 = new Model1({ a:1, b:3, c:3 });
a = m1.get('a'));
=> 1
source: gist.github.com/4684394
demo: bl.ocks.org/stepheneb/4684394
20130131
xxxxxxxxxx
<html>
<head>
<title>JavaScript Mixin Experiments</title>
<style type="text/css">
body { font: 16px sans-serif; }
p { font-size: 1.5em;
margin-left: 1.0em }
rect { fill: #fff; }
ul {
list-style-type: none;
margin: 0.5em 0em 0.5em 0em;
width: 100%; }
ul li {
margin: 0em;
padding: 0em 1em; }
</style>
</head>
<body>
<p>JavaScript Mixin Experiments</p>
<ul id="results"></ul>
<script>
resultsList = document.getElementById('results');
</script>
<script src='mixin.js' type='text/javascript'></script>
</body>
</html>