First off, you should read this MDN page. Quoting from that page:
Use of the with statement is not recommended, as it may be the source
of confusing bugs and compatibility issues. See the "Ambiguity Con"
paragraph in the "Description" section below for details.
and also:
Using with is not recommended, and is forbidden in ECMAScript 5 strict
mode. The recommended alternative is to assign the object whose
properties you want to access to a temporary variable.
Secondly, if I were writing your code, I would do it like this:
var home = {};
home.table = {
width: 100,
length: 200,
weight: 20,
material: 20,
color: "brown"
};
or, the whole thing can even be done in one JS literal:
var home = {
table: {
width: 100,
length: 200,
weight: 20,
material: 20,
color: "brown"
}
};
Here's an example using a temporary variable (as recommended as a substitute for with
by MDN) would be this - though in this case I would prefer the above format:
var home = {};
home.table = {};
var table = home.table;
table.width = 100;
table.length = 200;
table.weight = 20;
table.material = 20;
table.color = "brown";