HighDots Forums  

FAQ Topic - How do I access a property of an object using a string? (2008-05-24)

Javascript JavaScript language (comp.lang.javascript)


Discuss FAQ Topic - How do I access a property of an object using a string? (2008-05-24) in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
FAQ server
 
Posts: n/a

Default FAQ Topic - How do I access a property of an object using a string? (2008-05-24) - 05-23-2008 , 06:00 PM






-----------------------------------------------------------------------
FAQ Topic - How do I access a property of an object using
a string?
-----------------------------------------------------------------------

There are two ways to access properties: the dot notation and
the square bracket notation. What you are looking for is the square
bracket notation in which the dot, and the identifier to its right,
are replaced with a set of square brackets containing a string. The
value of the string matches the identifier. For example:-

//dot notation
var bodyElement = document.body;

//square bracket notation, using an expression
var bodyElement = document["bo"+"dy"];

http://www.jibbering.com/faq/faq_not..._brackets.html


--
Postings such as this are automatically sent once a day. Their
goal is to answer repeated questions, and to offer the content to
the community for continuous evaluation/improvement. The complete
comp.lang.javascript FAQ is at http://jibbering.com/faq/index.html.
The FAQ workers are a group of volunteers. The sendings of these
daily posts are proficiently hosted by http://www.pair.com.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.