Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Function.call prototype issue

 
Sanjiv Jivan
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was trying to write some OO Javascript where I have some code like

function Base() {}

Base.prototype.foo = function(){
..
}

Child.superclass = Base.prototype;

function Child(){}

Child.prototype.foo = function() {
Child.superclass.foo.call(this);
...
}

The foo() function in Child works on some IE JS versions, however I get a javascript error on some javascript versions stating that the "call" property is not defined in the line " Child.superclass.foo.call(this);"

I tried googling but could not find an definite answers as to which JS version the "call" functionality was introduced. Is there a better/alternate way to call a superclasses method?

Also is there a way to tell which JS version is running? The machine where I'm getting the error is also running IE 6, but seems to have an older JS version installed on it.

Thanks,
Sanjiv
[ June 02, 2006: Message edited by: Sanjiv Jivan ]
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
call() and apply() should work on IE 5.5 or greater.

I do not have time to look at your code right now to see if there is a problem.

Eric
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic