d.***********@i7.com.pl wrote:
I was wondering if the following could be better written:
var myObject = {};
/*
in this case explicit declaration seems to be mandatory
otherwise 'myObject.ala has no properties' error occurs
*/
Of course, `undefined' has no properties.
if (typeof myObject["ala"] == "undefined") {
myObject["ala"] = [];
}
This condition is only necessary if the "ala" property is running the risk
of not being defined or explicitly assigned `undefined' before.
myObject["ala"].push("ela");
Backwards compatible:
var myObject = new Object();
myObject.ala = new Array("ela");
or (ECMAScript 3 compliant):
var myObject = {ala: ["ela"]};
PointedEars
--
"Use any version of Microsoft Frontpage to create your site. (This won't
prevent people from viewing your source, but no one will want to steal it.)"
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>