Generally the with keyword is used to resolve long namespaces, not a single object reference. I guess I'd need to know what the intent of using the keyword here is. I don't believe the syntax parser will let you get away with o.bad:property
, which is basically what's being coded using with.
If the o
object in the example was just a shortcut to a longer namespace, my recommendation would be to stop one object short in the resolution using with, then put box your property into a string like this...
var nmSpace = new Object();
nmSpace.o = { "bad:property": 1, "goodProperty": 2 };
with (nmSpace) {
alert(o['goodProperty']); // works awesome
alert(o['bad:property']); // now accesses "bad:property"!
}
Hope that helps.