with: Some Good Example
OK, I have said my last post would have been the last one about the with statement ... well, before I close the argument, I would like to show a couple of common good examples. Solve References Problem This is what somebody defined a tiny masterpiece with({o:myreference}){ o.doStuff(); o.var1 = "whatever"; // etc etc ... }; Above example annihilate every blame about the not sure if that is the var I meant to use since there is an explicit reference as is, as example, in Python programming language (until version 3.11) // Python with open("x.txt") as f: data = f.read() // JavaScript equivalent with({f:/* as */open("x.txt")}) data = f.read() Memory Safe Operations Another recycled example before I show more interesting stuff ... apparently the whole problem is about write silly code inside with , as if everybody has to define variables or assign stuff inside this statement. Hilariously, I have basically never assigned anything inside a