JScript ユーザーズ ガイド、独自のオブジェクトの作成

まんま

function pasta(grain, width, shape, hasEgg)
{
  this.grain = grain;

  this.width = width;

  this.shape = shape;

  this.hasEgg = hasEgg;
}

var spaghetti = new pasta("wheat", 0.2, "circle", true);
var linguine = new pasta("wheat", 0.3, "oval", true);

spaghetti.color = "青っぽいわらの色";
spaghetti.drycook = 7;
spaghetti.freshcook = 0.5;

for (x in spaghetti) {
  WScript.Echo("spaghetti : ." + x + " = " + spaghetti[x]);
}
for (x in linguine) {
  WScript.Echo("linguine : ." + x + " = " + linguine[x]);
}


var chowFun = new pasta("米", 3, "平べったさ", false); 

pasta.prototype.foodgroup = "carbohydrates"

for (x in spaghetti) {
  WScript.Echo("spaghetti : ." + x + " = " + spaghetti[x]);
}
for (x in linguine) {
  WScript.Echo("linguine : ." + x + " = " + linguine[x]);
}
for (x in chowFun) {
  WScript.Echo("chowFun : ." + x + " = " + chowFun[x]);
}