Robert wrote:
> Hi,
>
> I can use "with" like this:
>
> function MyObject(message)
> {
> this.message = message;
> }
> function _MyObject_speak()
> {
> alert(this.message);
> }
>
> with (MyObject)
> {
> prototype.speak = _MyObject_speak;
> }
>
>
> I was wondering why I can't use "with" like this:
>
> with (MyObject.prototype)
> {
> speak = _MyObject_speak;
> }
Hi Robert,
When you use with(MyObject), you're accessing properties of MyObject
within that scope. Therefore, extending MyObject is valid.
However, when you use with(MyObject.prototype), you're accessing
properties of MyObject.prototype within that scope. Therefore, you're
not performing extensions to your MyObject.

So you just misunderstood the behavior of the with statement.
Hope this helps.