Some notes on javascript the core

Some notes on reading an article:  javascript the core Execution context(EC) VO Variable Object (VO): includes variables and function declarations.              function expression will not be included in the VO Activation Object (AO): include VO + function arguments In ES5, the VO and AO is combined into the lexical environments….

object vs closure

Consider this JavaScript function: 1 2 3 4 5 function fn() { var a = 10; var b = { name: ‘foo’, n: 10 }; } This might produce the following: I say “might” because specific behaviors depend heavily on implementation. This post takes a V8-centric approach with many diagram shapes linking to relevant source…

that=this in javascript

Watch Out: Callbacks And Closures Sometimes Do Not Play Nicely  Of course there are always gotchas with JavaScript. Lets define a callback function: 1 2 3 4 5 6 7 8 9 10 11 var createCallBack = function() { //First function return new function() { //Second function this.message = “Hello World”; return function() {…

javascrip closure

First, a very very good article explaining CLOSURE Second, I like this answer in Stackoverflow: A function in JavaScript is not just a reference to a set of instructions (as in C language) but also includes a hidden data structure which is composed of references to all nonlocal variables it uses (captured variables). Such two-piece…

groovy closure

Informal Guide When using the Java programming language most executable code is enclosed in either static class methods or instance methods. (Code can also be enclosed in constructors, initializers, and initialization expressions, but those aren’t important here.) A method encloses code within curly brackets and assigns that block of code a method name. All such…