- Dynamic Dispatch
- Dynamic Method
- Ghost Methods
- Dynamic Proxies
- Blank Slate
- Kernel Method
- Flattening the Scope (aka Nested Lexical Scopes)
- Context Probe
- Class Eval (not really a 'spell' more just a demonstration of its usage)
- Class Macros
# Get IAM Role name from Instance Profile Id | |
curl http://169.254.169.254/latest/meta-data/iam/info | |
# Get credentials | |
curl http://169.254.169.254/latest/meta-data/iam/security-credentials/<role-name> | |
# More info | |
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html | |
$(document).ready(function() { | |
$(document).on('click keypress', function(event) { | |
if (event.type == 'click' || event.which == 13) { | |
$(event.target).trigger('activate'); | |
} | |
}); | |
$("button").on('activate', function() { | |
alert('Button activated!'); | |
}); | |
}); |
JavaScript does not have "inheritance" or "prototypal inheritance" or "classes" or any of that jazz... what you've been told, and how you've been taught about it, are a misunderstanding... all this nonsense about constructor functions and new
and such... that's all hogwash... well, it's all unnecessary effort, at best.
"Instead... only try to realize the truth... there is no spoon."
What JavaScript does have is "behavior delegation"... and object linking through the "prototype chain"... you merely link two instances of objects together, say Foo
and Baz
, and say that Baz
"delegates" to Foo
for any behavior that Baz
doesn't own itself but that Foo
does own. And thus, any object b
(aka, "b is an instance of Baz" in the more confusing terminology) which is linked to Baz
, delegates first to Baz
, and then to Foo
, for behavior.
That's it. Seriously. And function constructors and new
and all that stuff, everything you've read before about OO in JS, they're just distractions that lea