• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

javascript reflection ?

 
Edward Chen
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to use javascript relection in an AJAX call ?



could I use some javascript reflection to invoke that method, like java reflection.. ?



Thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64958
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I assume firstName is a property. What method is there to invoke?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64958
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
P.S. As a functional language, JavaScript has no methods -- though we frequently call functions that are properties of objects a "method" (even though they're really not).
 
Edward Chen
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:I assume firstName is a property. What method is there to invoke?


Yes, it is a property. Assume we need to write a tool to dynamically get an object property in the runtime. How could we do it in the JS ?

Thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64958
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Still not sure what you are asking. To access a property, you just reference it.

Or are you looking for a way to discover what properties an object has? If so, check out the for...in statement.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34654
365
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Edward,
Do you mean something like this:
 
stef li
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i'm not clear about your question.
but i suggest you to research "js & class".
there may some useful articles for you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic