background preloader

Perfection kills » Understanding delete

Perfection kills » Understanding delete
A couple of weeks ago, I had a chance to glance through Stoyan Stefanov’s Object-Oriented Javascript. The book had an exceptionally high rating on Amazon (12 reviews with 5 stars), so I was curious to see if it was something worth recommending. I started reading through chapter on functions, and really enjoyed the way things were explained there; the flow of examples was structured in such nice, progressive way, it seemed even beginners would grasp it easily. However, almost immediately I stumbled upon an interesting misconception present throughout the entire chapter — deleting functions. The book claims that “function is treated as a normal variable—it can be copied to a different variable and even deleted.”. >>> var sum = function(a, b) {return a + b;} >>> var add = sum; >>> delete sum true >>> typeof sum; "undefined" Ignoring a couple of missing semicolons, can you see what’s wrong with this snippet? So what’s going on in this example? Theory§ but not variables, declared like this:

JSON for the masses Sunday Feb 19 2006 Your co-workers will love you for writing in JSON because it will most likely not conflict with their scripts that are being called within the same web documents. For Many Years... JavaScript has been portrayed as a very ugly language. Libraries like prototype, script.aculo.us, behavior, and Rico have all made their debut in 2005 and topping the charts of development circles as some of the greatest things to happen for web developers. Why? Because JSON is here. Reasons for JSON JSON is easy. No more fuss of writing function after function that has no meaning to which other group of functions it belongs to What is Object Notation in JavaScript? According to Douglas Corckford's website, JSON is a lightweight data-interchange format. As a simple example, Object Notation can be expressed in the following format: Sample Object Notation Reference Names Names can be anything except one of the JavaScript reserved keywords - which come to find out can actually be quite lengthy. Values

jQuery: The Write Less, Do More, JavaScript Library

Related: