View Single Post
  #3 (permalink)  
Old May 29th, 2008, 04:40 PM
YMas YMas is offline
Registered User
 
Join Date: May 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ciderpunx,
Thank you for your reply. Very much appreciated.

As you correctly point out above, the Java compiler will throw an exception if the argument of the function squared() is not an integer, whereas PERL will dynamically convert the string object into an integer and evaluate -- a consequence of loose typing.

In JavaScript, this would be an example of a constructor:
Code:
  function Car(color, type) {
    this.color = color;
    this.type = type;
  }
provided I invoke it like this:

Code:
  car1 = new Car('blue','SUV');
car1 is a reference to an object that behaves as the value of the "this" keyword.

I thought that this was a consequence of loose typing on the object type (I believe this is completely incorrect).

I can now see that this is a consequence of the way JavaScript was written i.e. it is a feature of JavaScript. Functions are data types and not just syntax.

Many thanks for your time.

Regards,
YMas
Reply With Quote