Win a copy of Event Streams in Action this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

how can I get the MyObject1 property testNumber

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

the instance of MyObject1 with the value of 8 assigned to its "testNumber" property is unaltered;
But how to find the MyObject1 property testNumber;
I am a newbie,by the way;
 
Marshal
Posts: 67273
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you were to run the script under a script debugger (built into all modern browsers except Firefox, into which you can install Firebug), you would see that this line fails:

var val = objectRef.prototype.testNumber;

The prototype property is not a property of just any object, but is a property of Function.

What are you actually trying to accomplish here? It doesn't seem like anything useful or with real-world applicability.
 
dean jack
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for your answer,you are right, will catch exception here.it should be .then I get the result is val==3(this peoperty is belong to MyObject2);I just want to know whether could I get the MyObject1 property 'testNumber';
it is not about real-world applicability,it's just my curiosity.so if no solution,it's doesn't matter.sorry,I am not good at english,must have some english syntax error above. please pardon me.
 
dean jack
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I knew the answer.
just save the 'new MyObject1( 8 )',then I can get the property of MyObject1;
I am so careless;
 
Bear Bibeault
Marshal
Posts: 67273
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you learned something, it was a useful exercise.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!