On Jun 11, 4:58 pm, "Ionut G. Stan" <[email protected]> wrote:
> On Jun 10, 6:41 pm, [email protected] wrote:
>
>
>
> > Hi there,
>
> > I'm looking to add a method to NativeArray/NativeJavaArray (preferably
> > both). Is there some way of doing this?
>
> > Currently, in JavaScript, I could do:
>
> > var a = [ 1, 2, 3, 4, 5, 6 ];
>
> > I can then call the method a.concat(), a.join(), etc. I can't seem to
> > find a way of getting a ScriptableObject of the prototype such that I
> > can then call defineMethod on it.
>
> > Is there any way to do this without having to start modifying the
> > Rhino source code?
>
> > Thanks,
> > Stewart
>
> Are you trying to do something like this?
>
> Array.prototype.getLentgh = function() {
>     return this.length;
>
> };
>
>


Forgot to add an example for the above code:

var a = [1, 2, 3];

print(a.getLength()); // outputs 3
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to