Prev: Limit of 4K
Next: Detecting Internet Explorer 6
From: kangax on 30 Oct 2009 16:29 Garrett Smith wrote: > kangax wrote: >> Here's a review of "Professional Javascript" by Zakas >> (http://thinkweb2.com/projects/prototype/professional-javascript-review/) >> >> The book is pretty big and I didn't have much time, so the coverage is >> not as extensive as it could have been. However, it should serve as a >> pretty good overview, highlighting pros and cons, and warning about >> some of the errors/misconceptions I encountered. >> > typo: > > localStorage.setItemt('clear', 'foo'); > > Should be: > > localStorage.setItem('clear', 'foo'); Thank you. Fixed. -- kangax
From: kangax on 30 Oct 2009 16:31 Garrett Smith wrote: > kangax wrote: >> Here's a review of "Professional Javascript" by Zakas >> (http://thinkweb2.com/projects/prototype/professional-javascript-review/) >> >> The book is pretty big and I didn't have much time, so the coverage is >> not as extensive as it could have been. However, it should serve as a >> pretty good overview, highlighting pros and cons, and warning about >> some of the errors/misconceptions I encountered. >> > > Wrong wording: > | I almost fully agree with everyone that�s being said here. > > s/everyone/everything Fixed too. Thanks. -- kangax
From: VK on 31 Oct 2009 13:17 Garrett Smith wrote: > Javascript variables are untyped. That's a wrong statement, you must be thinking of VBScript where indeed all variables independently on the current value are of the same Variant type. JavaScript is a *loosely typed* language, that means that each variable is of some certain type but this type can be changed to another one at runtime. > Null is a primitive value in javascript. Another wrong statement: null in JavaScript is an object with the only property null: window.alert(typeof null) // 'object' This way by assigning null to an object reference, we are dereferencing the said object. If it is the last existing reference then the relevant scavenger will be marked as garbage collection available on the next GC check. Not sure what is so alien here in comparison with other languages. > | Another misleading assertion was "Though ECMA-262 doesnt indicate a > | way to access the Global object directly [ ]". > > Plainly false. In global context: > > var global = this; Plainly false: in global context [this] refers to the window host object, not to Global. Let's do not mix "syntax sugar" added atop in some engine implementations with the actual mechanics, it might be dangerous.
From: Lasse Reichstein Nielsen on 31 Oct 2009 14:27 VK <schools_ring(a)yahoo.com> writes: > Garrett Smith wrote: >> Javascript variables are untyped. > > That's a wrong statement, you must be thinking of VBScript where > indeed all variables independently on the current value are of the > same Variant type. JavaScript is a *loosely typed* language, that > means that each variable is of some certain type but this type can be > changed to another one at runtime. Variables can have types in JavaScript 2.0, but not in ECMAScript so far. Values have types. Variables have a value, but not an inherent type. >> Null is a primitive value in javascript. > > Another wrong statement: null in JavaScript is an object with the only > property null: > window.alert(typeof null) // 'object' No, null is a primitive (i.e., non-object) value. Notice the specification of the typeof operator needs a special case for null, because it is not an object (ECMA 262 section 11.4.3). > This way by assigning null to an object reference, we are > dereferencing the said object. You can't assign a value to a value (object references are values), and I don't think "dereferencing" means what you think it means. > If it is the last existing reference > then the relevant scavenger will be marked as garbage collection > available on the next GC check. Not sure what is so alien here in > comparison with other languages. True, if you overwrite a variable holding an object reference with null, that might make the object eligable for garbage collection, but the same happens if you assign a number to the variable. Nothing non-primitive about null in that case. >> | Another misleading assertion was � "Though ECMA-262 doesn�t indicate a >> | way to access the Global object directly [�]". >> >> Plainly false. In global context: >> >> var global = this; > > Plainly false: in global context [this] refers to the window host > object, not to Global. What makes you think they are different? :) In a browser setting, the global object and the "this" value is actually not necessarily the same object, but ECMA-262 says nothing about browsers. It does say that the "this" value for code executed in a Global Context is the global object. If browsers differ, it's because they are not completely ECMA-262 compliant (with good reason, usually security related). /L -- Lasse Reichstein Holst Nielsen 'Javascript frameworks is a disruptive technology'
From: David Mark on 31 Oct 2009 14:30
On Oct 31, 1:17 pm, VK <schools_r...(a)yahoo.com> wrote: > Garrett Smith wrote: > > Javascript variables are untyped. > > That's a wrong statement, you must be thinking of VBScript where > indeed all variables independently on the current value are of the > same Variant type. JavaScript is a *loosely typed* language, that > means that each variable is of some certain type but this type can be > changed to another one at runtime. I doubt anyone is thinking of VBScript at this juncture. And you aren't thinking at all (as usual). > > > Null is a primitive value in javascript. > > Another wrong statement: null in JavaScript is an object with the only > property null: Wrong. > window.alert(typeof null) // 'object' That doesn't demonstrate your assertion. > This way by assigning null to an object reference, we are > dereferencing the said object. If it is the last existing reference > then the relevant scavenger will be marked as garbage collection > available on the next GC check. Not sure what is so alien here in > comparison with other languages. You are the alien here. > > > | Another misleading assertion was "Though ECMA-262 doesnt indicate a > > | way to access the Global object directly [ ]". > > > Plainly false. In global context: > > > var global = this; > > Plainly false: in global context [this] refers to the window host > object, not to Global. You can't learn browser scripting by observation and guesswork. > Let's do not mix "syntax sugar" added atop in > some engine implementations with the actual mechanics, it might be > dangerous. A little bit of knowledge is a dangerous thing. |