Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.mixmin.net!news2.arglkargh.de!noris.net!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail Content-Type: text/plain; charset="UTF-8" Message-ID: <1779068.4r8zmURcku@PointedEars.de> From: Thomas 'PointedEars' Lahn Reply-To: Thomas 'PointedEars' Lahn Organization: PointedEars Software (PES) Date: Mon, 24 Sep 2012 20:49:24 +0200 User-Agent: KNode/4.4.11 Content-Transfer-Encoding: 8Bit X-Face: %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&. <505dfcdb$0$6848$e4fe514c@news2.news.xs4all.nl> <02f07c90-fde4-4cc6-b44b-95239771c06d@m9g2000yqi.googlegroups.com> <7008a319-a3c7-43b4-9a05-dd1db287472f@l14g2000yqo.googlegroups.com> <0c5aab04-4fe4-41f8-b50f-ec9ea4821905@e18g2000yqo.googlegroups.com> Followup-To: comp.lang.javascript MIME-Version: 1.0 Lines: 70 NNTP-Posting-Date: 24 Sep 2012 20:49:24 CEST NNTP-Posting-Host: 76c518cf.newsspool3.arcor-online.net X-Trace: DXC=:Q8_koKOEH2LNKYb?b>076McF=Q^Z^V384Fo<]lROoR18kF1DZm8W4\YJN On Sep 23, 12:50 pm, Stefan Weiss wrote: >> On 2012-09-23 16:31, justaguy wrote: >> > Ok, I've implemented closure with my app, and now I see its beauty, in >> > the meantime, I don't know why >> > ++value; >> > would increment by 2. >> > I attempted with >> > +value to no avail >> >> The ++ operator increments by 1, not 2. >> The unary + operator does not increment at all. >> >> This is basic syntax. I think you would profit enormously from reading >> this guide: >> >> https://developer.mozilla.org/en-US/docs/JavaScript/Guide >> >> Chapter 5 is about expressions and operators, chapter 14 is about >> closures. > > Ok, back the my latest question/post, I guess I was almost correct, > manyCars are considered an object-like property, and it needs the " > like the following, > console.log(car["manyCars"]); // a: "Saab", "b": "Jeep" You are not making any sense. There are no "object-like properties" (there can be *array*-like *objects*, a completely different thing); these languages are loosely typed. Getters, setters and freezing (ES5) aside, any property can assume any value at any time. And a property's *value* is irrelevant to the *syntax* the property can be accessed with¹: console.log(car.manyCars); works as well, of course. The only case where the bracket accessor notation is required is when the property name is not an identifier, including when it is a reserved word.¹ (Whereas the latter has been fixed with ES 5, so one can hope that some day – perhaps 10 years from now – non-ES-5-conforming engines have gone.) What does not work well if `manyCars' is a reference to an object, is console.log(car[manyCars]); because property names are string values, so the value of `manyCars' would be converted to a string value there if it is not already is one. And for object references that means the toString() method of the object is called, which for built-in objects returns just "[object Object]". And there is no property with *that* name in your program. (JSX:map.js allows you to use objects as keys, refining the concept underlying jshashtable by Tim Down.) If you want to have any hope of understanding these languages (yes, it is not only one) some day, you should read a lot more carefully because I doubt anything in the JavaScript Guide suggests what you stated here. And you should stop posting via Google Groups using a pseudonym, because the people you want to be corrected by do not have the time to filter out your posting from all the other junk that is usually posted via Google Groups and by pseudonymous posters to Usenet. I am making an exception for this posting, of course. PointedEars ___________ ¹ And by convention and for clarity of code, it is useful when accessing DOM collections with ECMAScript implementations. -- Danny Goodman's books are out of date and teach practices that are positively harmful for cross-browser scripting. -- Richard Cornford, cljs, (2004)