Blog


I thought this was a great challenge and worthy of reposting.  It has to do with array selection and function expressions.

See if you can figure it out!

Read More

Well I know it’s been awhile since I’ve been updating this thread. Basically I’ve gotten busy with a number of things that have prevented from making updates.  I’m still reading the book… however I’ve been doing more real world interaction with JS which has kept me pretty busy.  In the mean time I’ve been reading this in conjunction with completing various tutorials at codeAcademy.com and codeschool.com  Unfortunately, that has caused me to make the decision to spend my future blogging time posting various tips and tricks that I come across....

Read More

So for chapter 4 there is quite a bit to cover. Here’s what I’m learning: PRIMITIVE AND REFERENCE VARIABLES Primitives variables hold a single piece of data… Reference variables carry multiple pieces of data Primitive reference values are that are referenced from new variable locations differently.  When referencing a primitive variable a new instance of the variable is copied to the new variable. Consider the following: var num1 = 5; var num2 = num1; // num1 will now be 5 However, reference variables point to the original variable value. This is because reference variables are stored in memory and when the reference variable is accessed, it’s accessing the same data in memory. (at least that’s how I understand it :P) Consider the following: var obj1 = new Object(); var obj2 = obj1; obj1.name = "Nicholas"; alert(obj2.name); //"Nicholas Variables are accessed both by value and by reference, but arguments are passed only by value. Variables are just data held in an object, Arguments are parameters set on functions or methods. To determine type, the typeof and instanceof operators are provided.  The typeof operator works well on primitive values and is used to help in the identification of primitive type variables. Here’s how it’s used: var s = "Nicholas"; var b = true; var i = 22; var u; var n = null; var o = new Object();console.log(typeof s); //string console.log(typeof i); //number console.log(typeof b); //boolean console.log(typeof u); //undefined console.log(typeof n); //object console.log(typeof o); //object The instanceof operator will return true if the variable is an instance of the given reference type. Here’s an example of it’s usage: console.log(person instanceof Object); //is the variable person an Object? console.log(colors instanceof Array); //is the variable colors an Array? console.log(pattern instanceof RegExp); //is the variable pattern a RegExp? EXECUTION CONTEXT AND SCOPE Each execution context has an associated variable object upon which all of its defined variables and functions exist. This object is not accessible by code but is used behind the scenes to handle data. Each function call has its own execution context. When code is executed in a context, a scope chain of variable objects is created. The chain is created to provide ordered access to all variables and functions.  The front of the scope chain is always the variable object of the context of whose code is executing.  Identifiers are resolved by navigating the scope chain in search of the identifier name and always begin at the front and work their way up to the global context variable object (the window object in the browser).  If it’s not found, an error occurs. Below is some code I wrote to illustrate how...

Read More