Drycodez Posted June 29, 2011 Share Posted June 29, 2011 I have seen lots and lots of js script with lots of dots/periods (.), but i just cant figure-out: how it works.e.g: name.name.value Link to comment Share on other sites More sharing options...
ShadowMage Posted June 29, 2011 Share Posted June 29, 2011 Chances are you are referring to these sort of statements:document.something.valuedocument.forms['something'].name.valueThose are really old school ways of accessing form elements. This way is not recommended. The preferred alternative is to give id's and use getElementById.You may also be referring to things like this:arr.lengthstr.toUpperCase()These are perfectly acceptable because those statements are accessing builtin properties/methods of objects. You may also come across custom defined objects, properties, and methods. These are also acceptable. Link to comment Share on other sites More sharing options...
boen_robot Posted June 29, 2011 Share Posted June 29, 2011 The general idea is that you have an object, and with the dot, you access a property of this object. The property of an object is itself an object, and return values from functions are also kinds of objects, so you can end up with really long chains of objects if you really want to. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.