2012-03-01から1ヶ月間の記事一覧
まんま function Circle(xPoint, yPoint, radius) { this.x = xPoint; this.y = yPoint; this.r = radius; } var aCircle = new Circle(5, 11, 99); Circle.prototype.pi = Math.PI; function ACirclesArea () { return this.pi * this.r * this.r; } Circle…
まんま var myObject = new Object(); var myBirthday = new Date(1961, 5, 10); まんま function Circle (xPoint, yPoint, radius) { this.x = xPoint; this.y = yPoint; this.r = radius; } var aCircle = new Circle(5, 11, 99);
まんま function pasta(grain, width, shape, hasEgg) { this.grain = grain; this.width = width; this.shape = shape; this.hasEgg = hasEgg; this.toString = pastaToString; } function pastaToString() { return "穀類: " + this.grain + "\n" + "幅: "…
まんま 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"…
ary = []; ary[0] = []; ary[0][0] = []; ary[0][0][0] = 1; ary[0][0][1] = 2; ary[0][1] = []; ary[0][1][0] = 10; ary[0][1][1] = 20; ary[0][1][2] = 30; ary[1] = []; ary[1][0] = 100; for (x in ary) { if (ary[x] instanceof Array) { for (xx in ar…
ほぼ、まんま var myArray = new Array(3); myArray[0] = "Hello"; myArray[1] = 42; myArray[2] = new Date(2000, 1, 1); WScript.Echo(myArray.length); myArray.expando = "JScript!"; myArray["another Expando"] = "Windows"; WScript.Echo(myArray.len…
かなり、まんま var myObj = new Object(); myObj.name = "Fred"; myObj.age = 42; WScript.Echo(myObj); for (x in myObj) { WScript.Echo(x); } WScript.Echo(myObj["name"]); WScript.Echo(myObj["age"]); myObj["name"] = "FRED"; WScript.Echo(myObj["n…
length の値を変更すると、縮小 ary = [1, 2, 3]; WScript.Echo(ary.length); ary.length = 2; for (x in ary) { WScript.Echo(ary[x]); } ary.length = 3; for (x in ary) { WScript.Echo(ary[x]); } 範囲外に代入すると、伸張 ary = [1, 2, 3]; WScript.Ec…
function foo() { WScript.Echo("foo"); } function foo(x, y) { WScript.Echo("FOO"); } foo(); 定義の括弧は必須のようだ 呼び出し側の括弧もないと関数呼び出しだと認識されないようだ 重複定義は、後で定義したものが有効っぽい 呼び出し側と定義側で関…
WScript.Echo(eval("x = 1 + 2 * 3;")); WScript.Echo("x : " + x); なぜここで、eval の説明が出てくるんだろう?
/*@cc_on @*/ WScript.Echo("@_win32 : " + @_win32); WScript.Echo("@_win16 : " + @_win16); WScript.Echo("@_mac : " + @_mac); WScript.Echo("@_alpha : " + @_alpha); WScript.Echo("@_x86 : " + @_x86); WScript.Echo("@_mc680x0 : " + @_mc680x0); WS…
まんま /*@cc_on @*/ /*@if (@_jscript_version >= 4) WScript.Echo("JScript バージョン 4 以降です。"); @else @*/ WScript.Echo("最新のスクリプト エンジンが必要です。"); /*@end @*/ 「@set ステートメント」不明
i = 0 while (true) { i++; if (i == 1) continue; WScript.Echo(i); if (i == 2) break; }
i = 0 do { WScript.Echo(i); i++; } while (i < 3);
i = 0 while (i < 3) { WScript.Echo(i); i++; }
ary = [10, 20, 30]; for (x in ary) { WScript.Echo(x + " : " + ary[x]); } まんま var myObject = new Object(); myObject.name = "James"; myObject.age = "22"; myObject.phone = "555 1234"; for (prop in myObject) { WScript.Echo("プロパティ '" + …
for (i = 0; i < 2; i++) { WScript.Echo(i); }
WScript.Echo(true ? "then" : "else"); WScript.Echo(false ? "then" : "else");
if (true) { WScript.Echo("then"); } else { WScript.Echo("else"); }
まんま var string1 = "Hello"; var string2 = "Hello"; var StringObject1 = new String(string1); var StringObject2 = new String(string2); WScript.Echo(string1 == string2); // -1 WScript.Echo(StringObject1 == StringObject2); // 0 WScript.Echo(…
WScript.Echo(new Object); WScript.Echo(new Object()); WScript.Echo(new Array()); WScript.Echo(new Date()); WScript.Echo(new Date("Jan 5 1996"));
WScript.Echo(new Array() instanceof Array); // -1 WScript.Echo(new Array() instanceof Object); // -1 WScript.Echo(new Array() instanceof Date); // 0 WScript.Echo(new Array() instanceof String); // 0
WScript.Echo(void 1); WScript.Echo(typeof(void 1)); // undefined
WScript.Echo(typeof 1); WScript.Echo(typeof(1)); WScript.Echo(typeof "1"); WScript.Echo(typeof true); WScript.Echo(typeof new String()); WScript.Echo(typeof function() {}); WScript.Echo(typeof x);
ary = [1,2,3] WScript.Echo(ary[0]); WScript.Echo(ary[1]); WScript.Echo(ary[2]); delete(ary[2]); WScript.Echo(ary[2]);
WScript.Echo(-1 >> 1); WScript.Echo(-1 >>> 1); // 符号なし
WScript.Echo(1 == "1"); // -1 WScript.Echo(1 === "1"); // 0 WScript.Echo(1 != "1"); // 0 WScript.Echo(1 !== "1"); // -1 WScript.Echo(1 == "1"); // 0
// WScript.Echo(x == undefined); WScript.Echo(typeof(x) == undefined); // 0 WScript.Echo(typeof(x) == "undefined"); // -1 WScript.Echo(String.prop); WScript.Echo(String.prop == null); // -1 WScript.Echo("prop" in String); // 0
var x; WScript.Echo(true); // -1 WScript.Echo(false); // 0 if (0) { WScript.Echo("0 then"); } else { WScript.Echo("0 else"); } if (null) { WScript.Echo("null then"); } else { WScript.Echo("null else"); } if (x) { WScript.Echo("undefined th…
WScript.Echo(010); WScript.Echo(0x10); WScript.Echo(0xf); WScript.Echo(0xF); WScript.Echo(0.0001); WScript.Echo(.0001); WScript.Echo(1e-4); WScript.Echo(0378); // 378 WScript.Echo(0377); // 255 //WScript.Echo(00.0001); 「正の 0 および負の …