継続は力にゃりん。毎日続けることができるのか? 進捗 * 2006-11-03 終了 * 2006-10-23 基本構文 * 2006-10-10 Object * 2006-09-21 RegExp * 2006-09-10 Function * 2006-09-01 Date * 2006-08-20 Math * 2006-08-03 Array * 2006-08-02 Boolean * 2006-07-11 String * 2006-07-02 Number * 2006-06-22 ビルトイン関数 * 2006-06-19 数値・文字列・定数 * 2006-06-01 演算子 !2006-11-03 Fri js> with(x) { print(x.toString(2)); print(x.toString(16)); } 1010 a なんで、x.with みたいなのじゃないのだろうか? !2006-11-02 Thu js> for (i = 0; i < 3; i++) { if (i == 1) continue; print(i); } 0 2 !2006-11-01 Wed js> loop:; js> print("loop:"); loop: js> for (i = 0; i < 3; i++) { if (i == 1) break loop; 4: SyntaxError: label not found: 4: if (i == 1) break loop; 4: ....................^ ラベル使えない??? !2006-10-31 Tue js> for (i = 0; i < 3; i++) { if (i == 1) break; print(i); } 0 !2006-10-30 Mon js> for (x in [0, 1, 2]) print(x); 0 1 2 !2006-10-29 Sun js> for (i = 0; i < 3; i++) print(i); 0 1 2 !2006-10-28 Sat js> i = 0; 0 js> do { print(i); i++; } while (i < 3); 0 1 2 2 !2006-10-27 Fri js> i = 0; 0 js> while (i < 3) { print(i); i++; } 0 1 2 2 !2006-10-26 Thu swiatch 文 js> switch (1) { case 1: print("1"); case 2: print("1 or 2"); break; default: print("default"); } 1 1 or 2 !2006-10-25 Wed if 文 js> if (true) print("true") true js> if (false) print("true") else print("false") 2: SyntaxError: missing ; before statement: 2: if (false) print("true") else print("false") 2: .........................^ js> if (false) print("true"); else print("false") false js> if (true) { print("true") } else { print("false") } true !2006-10-24 Tue 行の継続、コメント js> x = 1; 1 js> // foo js> /* foo */ !2006-10-23 Mon まず、標準出力って? js> document.write("Hello World!!"); 1: ReferenceError: document is not defined js> write("Hello World!!"); 2: ReferenceError: write is not defined js> print("Hello World!!"); Hello World!! js> !2006-10-22 Sun js> function foo() {} js> ({ x : 1, y : 2}).watch("x", foo) !2006-10-21 Sat js> (new Object).toSource() ({}) js> (new Date).toSource() (new Date(1161313175469)) js> { x : 1, y : 2}.toString() 9: SyntaxError: invalid label: 9: { x : 1, y : 2}.toString() 9: ...........^ js> ({ x : 1, y : 2}).toString() [object Object] js> ({ x : 1, y : 2}).toSource() ({x:1, y:2}) !2006-10-20 Fri js> (new Object).valueOf() [object Object] js> 1.valueOf() 2: SyntaxError: missing ; before statement: 2: 1.valueOf() 2: ..^ js> (1).valueOf() 1 js> (new Date(0)).valueOf() 0 js> (new Date(1)).valueOf() 1 js> (new Date).valueOf() 1161313160300 !2006-10-19 Thu js> (new Date).toString() Thu Oct 19 2006 12:06:54 GMT+0900 (JST) js> /foo/.toString() /foo/ js> (new Object).toString() [object Object] !2006-10-18 Wed js> (new Object()).eval("1+2") 3 js> (new Object).eval("1+2") 3 js> eval("1+2") 3 !2006-10-17 Tue js> "bar".foo js> String.prototype.foo = "foo" foo js> "bar".foo foo !2006-10-16 Mon js> (new Object()).constructor function Object() { [native code] } !2006-10-15 Sun js> new Object() [object Object] !2006-10-14 Sat 継承 js> function Point(x, y) { this.x = x; this.y = y; this.toString = function () { return ("(" + this.x + ", " + this.y + ")"); } } js> function PointX() { this.z = this.arguments.pop(); Point.apply(this, this.arguments); } js> new PointX(1,2) 9: TypeError: this.arguments has no properties js> new PointX(1,2,3) 9: TypeError: this.arguments has no properties ? this をつけなくてもエラーなんだけど… js> function Point(x, y) { this.x = x; this.y = y; this.toString = function () { return ("(" + this.x + ", " + this.y + ")"); } } js> function PointX() { this.z = arguments.pop(); Point.apply(this, arguments); } js> new PointX(1,2) 9: TypeError: arguments.pop is not a function !2006-10-13 Fri 継承 js> function Point(x, y) { this.x = x; this.y = y; this.toString = function () { return ("(" + this.x + ", " + this.y + ")"); } } js> function Point3(x, y, z) { this.z = z; Point.call(this, x, y); } js> new Point(1,2) (1, 2) js> new Point3(1,2,3) (1, 2) js> function Point3(x, y, z) { this.z = z; Point.call(this, x, y); this.toString = function () { return ("(" + this.x + ", " + this.y + ", " + this.z + ")"); } } js> new Point3(1,2,3) (1, 2, 3) !2006-10-12 Thu js> x = { x : 1, y : 2} [object Object] js> x.x 1 js> x.y 2 * メソッドの追加はできるの? * 構造体っぽい使い方? !2006-10-11 Wed js> function Point(x, y) { this.x = x; this.y = y; this.toString = function () { return ("(" + this.x + ", " + this.y + ")"); } } js> new Point() (undefined, undefined) js> new Point(1, 2) (1, 2) !2006-10-10 Tue js> function Foo () { } js> new Foo() [object Object] js> function Foo () { this.toString = function () { "Foo" } } js> new Foo() undefined js> function Foo () { this.toString = function () { return "Foo" } } js> new Foo() Foo !2006-10-09 Mon js> "foo bar baz".split(" ") foo,,bar,,baz js> "foo bar baz".split(/\s+/) foo,bar,baz !2006-10-08 Sun js> "foo 123 bar".match(/\d+/) 123 js> RegExp.lastMatch 123 js> RegExp.leftContext foo js> RegExp.rightContext bar js> RegExp.lastParen js> "foo 123 bar".match(/(\d+)/) 123,123 js> RegExp.lastParen 123 !2006-10-07 Sat js> re = /\d+/ /\d+/ js> "foo 123".match(re) 123 js> re.lastIndex 0 js> "foo 123 bar".match(re) 123 js> re.lastIndex 0 ? !2006-10-06 Fri js> "foo 123".match(/\d+/) 123 js> RegExp.index js> RegExp.lastIndex ない? !2006-10-05 Thu js> RegExp.multiline false js> /^123/.exec("abc\n123") null js> RegExp.multiline = true true js> /^123/.exec("abc\n123") 123 !2006-10-04 Wed js> $_ = "bar" bar js> /\S+/.exec() 2: SyntaxError: no input for /\S+/ ? !2006-10-03 Tue js> RegExp.input = "foo" foo js> /\S+/.exec() foo js> RegExp.lastMatch foo !2006-10-02 Mon js> re = /\S+/ /\S+/ js> re.exec("foo bar") foo js> re.exec("foo bar") foo js> re.exec("foo bar") foo js> re = /\S+/g /\S+/g js> re.exec("foo bar") foo js> re.exec("foo bar") bar js> re.exec("foo bar") null js> re.exec("foo bar") foo js> re.exec("foo bar") bar ふーん !2006-10-01 Sun js> re = new RegExp /(?:)/ js> re.compile("\\S+") /\S+/ js> re.test("foo bar") true js> re.exec("foo bar") foo js> re.compile("\\S+", "g") /\S+/g js> re.exec("foo bar") foo js> re = new RegExp() /(?:)/ !2006-09-30 Sat js> /\S+/.test("foo bar") true js> /\S+\s+\S+/.test("foo bar") true js> /\S+\s+\S+\s+/.test("foo bar") false !2006-09-29 Fri js> /\S+/("foo bar") foo js> /\S+\s+\S+/("foo bar") foo bar js> /(\S+)/g("foo bar") foo,foo js> /\S+/.exec("foo bar") foo js> /\S+\s+\S+/.exec("foo bar") foo bar js> "foo bar".match(/\S+\s+\S+/) foo bar js> /\S+/.exec() foo js> RegExp.input foo bar !2006-09-28 Thu js> "foo bar baz".match(/(\S+)/) foo,foo js> "foo bar baz".match(/(\S+)/g) foo,bar,baz js> x = "foo bar baz".match(/(\S+)/) foo,foo js> x[0] foo js> x[1] foo !2006-09-27 Wed js> "foo bar foo".match(/(\S+)\s+(\S+)\s+\1/) foo bar foo,foo,bar js> "foo bar bar".match(/(\S+)\s+(\S+)\s+\1/) null js> "foo bar foo bar".match(/(\S+)\s+(\S+)\s+\1\s+\2/) foo bar foo bar,foo,bar !2006-09-26 Tue js> "foo bar".match(/(\S+)\s+(\S+)/) foo bar,foo,bar js> RegExp.$1 foo js> RegExp.$2 bar js> RegExp.$& 戻ってこなくなった〜 js> " foo bar 123".match(/(\S+)\s+(\S+)/) foo bar,foo,bar js> RegExp.lastMatch foo bar js> RegExp.leftContext js> RegExp.rightContext 123 js> RegExp.lastParen bar js> RegExp.input foo bar 123 js> RegExp.multiline false !2006-09-25 Mon js> new RegExp("foo").multiline false js> new RegExp("foo", "m").multiline true js> /foo/.multiline false js> /foo/m.multiline true !2006-09-24 Sun js> new RegExp("foo").source foo js> /foo/.source foo js> /^foo$/.source ^foo$ !2006-09-23 Sat js> new RegExp("foo").global false js> new RegExp("foo", "g").global true js> /foo/.global false js> /foo/g.global true !2006-09-22 Fri js> /foo/.ignoreCase false js> /foo/i.ignoreCase true js> (/foo/i).ignoreCase true js> new RegExp("foo").ignoreCase false js> new RegExp("foo", "i").ignoreCase true !2006-09-21 Thu js> re = new RegExp("foo") /foo/ js> "foo".match(re) foo js> "bar".match(re) null js> "foo bar".match(re) foo js> "FOO".match(re) null js> "FOO".match(/foo/i) FOO !2006-09-20 Wed js> function foo() { } js> foo.apply() js> function foo(x, y) { return x + y; } js> foo.apply() NaN js> foo.apply(null, [1,2]) 3 js> foo.apply(null, 1,2) 7: TypeError: second argument to Function.prototype.apply must be an array !2006-09-19 Tue js> foo = new Function("x", "x", "return x + y;") function anonymous(x, x) { return x + y; } js> foo(1,2) 1: ReferenceError: y is not defined js> foo = new Function("x", "y", "return x + y;") function anonymous(x, y) { return x + y; } js> foo(1,2) 3 js> foo = new Function("x,y", "return x + y;") function anonymous(x, y) { return x + y; } js> foo(1,2) 3 !2006-09-18 Mon js> function foo() { } js> foo(null) js> foo.call(null) js> function foo() { return 1; } js> foo.call(null) 1 js> foo.call() 1 js> function foo(x, y) { return x + y; } js> foo.call() NaN js> foo.call(1) NaN js> foo.call(1,2) NaN js> foo.call(null, 1,2) 3 js> foo.call(10,1,2) 3 !2006-09-17 Sun js> function foo() { } js> foo.prototype [object Object] !2006-09-16 Sat js> function foo(x, y) { return foo.caller; } js> foo() null js> function hoge() { foo(); } js> hoge() js> function hoge() { return foo(); } js> hoge() function hoge() { return foo(); } !2006-09-15 Fri js> function foo(x, y) { return foo.arguments; } js> foo(1,2) [object Object] js> foo(1,2,3) [object Object] js> function foo(x, y, z) { return foo.arguments; } js> foo(1,2,3) [object Object] js> x = foo(1,2,3) [object Object] js> x[0] 1 js> x[1] 2 js> x[2] 3 js> function foo(x, y, z) { return foo.arguments.length; } js> foo(1) 1 js> foo(1,2) 2 js> foo(1,2,3) 3 js> foo(1,2,3,4) 4 !2006-09-14 Thu ちょい寄り道 js> function foo() { return foo; } js> foo() function foo() { return foo; } js> foo()() function foo() { return foo; } js> (foo())() function foo() { return foo; } js> f = foo() function foo() { return foo; } js> f function foo() { return foo; } js> f() function foo() { return foo; } ? !2006-09-13 Wed js> function foo() {} js> foo.arity 0 js> function foo(x, y) {} js> foo.arity 2 !2006-09-12 Tue js> foo0 = new Function("return 0;") function anonymous() { return 0; } js> foo0() 0 js> foo = new Function("x", "return x;") function anonymous(x) { return x; } js> foo(1) 1 js> foo() js> foo(1, 2) 1 js> foo = new Function("x", "x", "return x + x;") function anonymous(x, x) { return x + x; } js> foo(1) NaN js> foo(1,2) 4 js> function foo(x, x) { return x + x; } js> foo(1,2) 4 !2006-09-11 Mon js> x = 10; 10 js> function foo() { x = 20;} js> foo() js> x 20 js> function foo() { var x = 30;} js> foo() js> x 20 js> function foo(x) { x = 30;} js> foo() js> x 20 !2006-09-10 Sun js> function foo0() { return 0; } js> foo0() 0 js> function foo0() { 0 } js> foo0() js> function foo0() { 0; } js> foo0() return は必要か〜 js> function add(a, b) { return a + b; } js> add(1, 2) 3 !2006-09-09 Sat js> new Date(0) Thu Jan 01 1970 09:00:00 GMT+0900 (JST) js> new Date(0) Thu Jan 01 1970 09:00:00 GMT+0900 (JST) js> Date(0) Fri Sep 08 2006 12:03:12 GMT+0900 (JST) ? !2006-09-08 Fri js> Date.parse("Sep 1, 2006 12:00:00") 1157079600000 js> new Date("Sep 1, 2006 12:00:00").getTime() 1157079600000 !2006-09-07 Thu js> Date.UTC(1970, 0, 1, 0, 0, 0) 0 js> Date.UTC(1970, 0, 1, 0, 0, 1) 1000 js> Date.UTC(1970, 0, 1, 0, 0, 0, 1) 1 !2006-09-06 Wed js> new Date().getTime() 1157511698571 setTime とばし !2006-09-05 Tue js> d = new Date() Tue Sep 05 2006 12:00:13 GMT+0900 (JST) js> d.toString() Tue Sep 05 2006 12:00:13 GMT+0900 (JST) js> d.toLocaleString() Tue Sep 5 12:00:13 2006 js> d.toGMTString() Tue, 05 Sep 2006 03:00:13 GMT js> d.toUTCString() Tue, 05 Sep 2006 03:00:13 GMT js> d.toVarDate() 10: TypeError: d.toVarDate is not a function !2006-09-04 Mon js> new Date().getTimezoneOffset() -540 60*9 か !2006-09-03 Sun js> new Date().getUTCFullYear() 2006 js> new Date().getUTCYear() 26: TypeError: (new Date()).getUTCYear is not a function js> new Date().getUTCMonth() 8 js> new Date().getUTCDate() 1 js> new Date().getUTCDay() 5 js> new Date().getUTCHours() 3 js> new Date().getUTCMinutes() 8 js> new Date().getUTCSeconds() 6 js> new Date().getUTCMilliseconds() 499 set の方はとばし !2006-09-02 Sat js> new Date().getFullYear() 2006 js> new Date().getYear() 106 js> new Date().getMonth() 8 js> new Date().getDate() 1 js> new Date().getDay() 5 js> new Date().getHours() 12 js> new Date().getMinutes() 6 js> new Date().getSeconds() 3 js> new Date().getMilliseconds() 67 set の方はとばし !2006-09-01 Fri js> new Date(2006, 9, 1); Sun Oct 01 2006 00:00:00 GMT+0900 (JST) js> new Date(2006); Thu Jan 01 1970 09:00:02 GMT+0900 (JST) js> new Date(2006, 9); Sun Oct 01 2006 00:00:00 GMT+0900 (JST) js> new Date(2006, 9, 1); Sun Oct 01 2006 00:00:00 GMT+0900 (JST) js> new Date(2006, 8, 1); Fri Sep 01 2006 00:00:00 GMT+0900 (JST) js> new Date(); Fri Sep 01 2006 12:02:25 GMT+0900 (JST) js> new Date("Sep 1, 2006 12:00:00"); Fri Sep 01 2006 12:00:00 GMT+0900 (JST) js> new Date("2006/9/1 12:00:00"); Fri Sep 01 2006 12:00:00 GMT+0900 (JST) js> new Date("9/1/2006 12:00:00"); Fri Sep 01 2006 12:00:00 GMT+0900 (JST) js> new Date("06/9/1 12:00:00"); Sun Jun 09 1901 12:00:00 GMT+0900 (JST) js> new Date("99/9/1 12:00:00"); Wed Sep 01 1999 12:00:00 GMT+0900 (JST) js> new Date("9/1/99 12:00:00"); Wed Sep 01 1999 12:00:00 GMT+0900 (JST) js> new Date(2006, 8, 1, 12, 0, 0, 0); Fri Sep 01 2006 12:00:00 GMT+0900 (JST) js> new Date(2006, 8, 1, 12, 0, 0, 0, 0); Fri Sep 01 2006 12:00:00 GMT+0900 (JST) js> new Date(2006, 8, 1, 12, 0, 0, 0, 0, 0); Fri Sep 01 2006 12:00:00 GMT+0900 (JST) !2006-08-31 Thu js> Math.pow(2, 3) 8 js> Math.sqrt(2) 1.4142135623730951 js> Math.exp(1) 2.718281828459045 js> Math.log(0) -Infinity js> Math.log(1) 0 js> Math.log(Math.E) 1 !2006-08-30 Wed js> Math.max(1, 2) 2 js> Math.max(2, 1) 2 js> Math.min(1, 2) 1 js> Math.min(2, 1) 1 js> Math.max(2, 1, 0) 2 js> Math.max(1, 2, 3, 4, 5) 5 js> Math.max([1, 2, 3, 4, 5]) NaN !2006-08-29 Tue js> Math.PI 3.141592653589793 js> Math.SQRT2 1.4142135623730951 js> Math.SQRT1_2 0.7071067811865476 js> Math.E 2.718281828459045 js> Math.LN2 0.6931471805599453 js> Math.LN10 2.302585092994046 js> Math.LOG2E 1.4426950408889634 js> Math.LOG10E 0.4342944819032518 !2006-08-28 Mon js> Math.asin(0) 0 js> Math.acos(1) 0 js> Math.atan(1) 0.7853981633974483 js> Math.atan2(0, 0) 0 !2006-08-27 Sun js> Math.tan(Math.PI/4) 0.9999999999999999 !2006-08-26 Sat js> Math.cos(0) 1 js> Math.cos(Math.PI/2) 6.123031769111886e-17 !2006-08-25 Fri js> Math.sin(0) 0 js> Math.sin(Math.PI/4) 0.7071067811865475 js> Math.sin(Math.PI/2) 1 !2006-08-24 Thu js> Math.abs(-1) 1 js> Math.abs(-1.2) 1.2 !2006-08-23 Wed js> Math.round(-1.9) -2 js> Math.round(-1.2) -1 js> Math.round(-0.9) -1 js> Math.round(-0.2) 0 js> Math.round(0.2) 0 js> Math.round(0.9) 1 js> Math.round(1.2) 1 js> Math.round(1.9) 2 js> Math.round(1.4) 1 js> Math.round(1.5) 2 !2006-08-22 Tue js> Math.floor(-1.9) -2 js> Math.floor(-1.2) -2 js> Math.floor(-0.9) -1 js> Math.floor(-0.2) -1 js> Math.floor(0.2) 0 js> Math.floor(0.9) 0 js> Math.floor(1.2) 1 js> Math.floor(1.9) 1 !2006-08-21 Mon js> Math.ceil(-1.9) -1 js> Math.ceil(-1.2) -1 js> Math.ceil(-0.9) 0 js> Math.ceil(-0.2) 0 js> Math.ceil(0.2) 1 js> Math.ceil(0.9) 1 js> Math.ceil(1.2) 2 !2006-08-20 Sun js> Math [object Math] js> Math.random() 0.21862627662526102 js> Math.random() 0.3746750266629789 !2006-08-19 Sat js> a = [1, 2, 3, 4, 5, 6] 1,2,3,4,5,6 js> a.length 6 js> a.length = 3 3 js> a 1,2,3 !2006-08-18 Fri js> a = Array(1, 2, 3) 1,2,3 js> a 1,2,3 js> a = Array(1, , , , 3) 3: SyntaxError: syntax error: 3: a = Array(1, , , , 3) 3: .............^ js> a = [1, , , , 3] 1,,,,3 !2006-08-17 Thu js> a = new Array() js> a["foo"] = 1 1 js> a["bar"] = 20 20 js> a["baz"] = 30 30 js> a js> a["foo"] 1 js> a["bar"] 20 js> a["baz"] 30 js> a.sort() js> a.push(10) 1 js> a.push(100) 2 js> a.push(1000) 3 js> a 10,100,1000 なんか良く分からないなあ〜 !2006-08-16 Wed js> new Array(1, 2, 3, 4, 5, 6).reverse() 6,5,4,3,2,1 js> new Array(6, 5, 4, 3, 2, 1).reverse() 1,2,3,4,5,6 !2006-08-15 Tue js> new Array(6, 5, 4, 3, 2, 1).sort() 1,2,3,4,5,6 js> a = new Array(6, 5, 4, 3, 2, 1) 6,5,4,3,2,1 js> a.sort() 1,2,3,4,5,6 js> a 1,2,3,4,5,6 js> function my_cmp(a, b) { if (a > b) {return -1} else if (a < b) {return 1} else {return 0} } js> new Array(1, 2, 3, 4, 5, 6).sort(my_cmp)6,5,4,3,2,1 js> new Array("foo", "bar", "baz").sort() bar,baz,foo これも(python ぽく)破壊的か !2006-08-14 Mon js> a = new Array(1, 2, 3, 4, 5, 6) 1,2,3,4,5,6 js> a.splice(0, 0) js> a 1,2,3,4,5,6 js> a.splice(0, 1) 1 js> a 2,3,4,5,6 js> a.splice(0, 1, 10, 20) 2 js> a 10,20,3,4,5,6 !2006-08-13 Sun js> a = new Array(1, 2, 3, 4, 5, 6) 1,2,3,4,5,6 js> a.slice(0, 0) js> a 1,2,3,4,5,6 js> a.slice(0, 1) 1 js> a 1,2,3,4,5,6 js> a.slice(0, 2) 1,2 js> a 1,2,3,4,5,6 js> a.slice(0, 2, 10) 1,2 js> a 1,2,3,4,5,6 js> a.slice(0, 2, 10, 11) 1,2 js> a 1,2,3,4,5,6 ?と思ったら、splice と slice を間違えた… 引数が多くても文句言わないんだな〜 !2006-08-12 Sat js> a = new Array(1, 2, 3) 1,2,3 js> a.pop() 3 js> a 1,2 !2006-08-11 Fri js> a = new Array(1, 2, 3) 1,2,3 js> a.shift function shift() { [native code] } js> a.shift() 1 js> a 2,3 !2006-08-10 Thu js> a = new Array(1, 2, 3) 1,2,3 js> a.push(4) 4 js> a 1,2,3,4 js> a = new Array(1, 2, 3) 1,2,3 js> a.push(4,5,6) 6 js> a 1,2,3,4,5,6 !2006-08-09 Wed js> new Array(1, 2, 3).unshift(4) 4 js> a = new Array(1, 2, 3) 1,2,3 js> a.unshift(4) 4 js> a 4,1,2,3 js> a.unshift(-3,-2,-1,0) 7 js> a -3,-2,-1,0,1,2,3 めずらしく、中身が更新されるようだ !2006-08-08 Tue そもそも、[ ] でも表記できるっぽいのだが、、 js> [1, 2, 3] 1,2,3 js> [1] 1 js> typeof([1]) object js> typeof([1, 2]) object !2006-08-07 Mon js> new Array("foo", "bar", "baz").join(":") foo:bar:baz js> new Array("foo", "bar", "baz").join() foo,bar,baz js> new Array(1, 2, 3).join() 1,2,3 js> new Array(1, 2, 3).join(":") 1:2:3 !2006-08-06 Sun js> a = new Array(1,2,3) 1,2,3 js> a.concat(new Array(4,5,6)) 1,2,3,4,5,6 js> a 1,2,3 js> a.concat(new Array(4,5,6), new Array(7,8,9)) 1,2,3,4,5,6,7,8,9 !2006-08-05 Sat js> a = new Array() js> a["foo"] = 1 1 js> a[0] = 10 10 js> a 10 ? js> a["foo"] 1 js> a[0] 10 !2006-08-04 Fri js> a = new Array() js> a[0] = new Array() js> a[0][0] = 1 1 js> a[0][1] = 1 1 js> a[1] = 2 2 js> a 1,1,2 js> a[2][0] 11: TypeError: a[2] has no properties !2006-08-03 Thu js> new Array() js> a = new Array() js> typeof(a) object js> new Array(1) js> new Array(2) , js> new Array(3) ,, js> a = new Array(3) ,, js> a[3] js> a[4] js> new Array(1, 2, 3) 1,2,3 js> new Array(1, 2, 3, "foo", "bar", "baz") 1,2,3,foo,bar,baz js> new Array().length 0 js> new Array(1).length 1 js> new Array(2).length 2 js> new Array(1,2,3).length 3 !2006-08-02 Wed js> true true js> false false js> new Boolean(true) true js> new Boolean(false) false js> new Boolean(1) true js> new Boolean(0) false js> new Boolean("a") true js> new Boolean("") false js> new Boolean(new Boolean(false)) true !2006-08-01 Tue js> "foo".match(/\w+/) foo js> "foo".match('\w+') null js> "foo".match("\\w+") foo js> "foo".search(/\w+/) 0 js> "foo".search('\w+') -1 js> "foo".search('\\w+') 0 !2006-07-31 Mon js> "foo".toLocaleUpperCase() FOO js> "FOO".toLocaleLowerCase() foo !2006-07-30 Sun js> "abc".localeCompare("abc") 0 js> "abc".localeCompare("abcd") -1 js> "abc".localeCompare("ABC") 32 js> "abc".localeCompare("aaa") 1 !2006-07-29 Sat js> "abc".bold() abc js> "abc".italics() abc js> "abc".fixed() abc js> "abc".big() abc js> "abc".small() abc js> "abc".blink() abc js> "abc".strike() abc js> "abc".sup() abc js> "abc".sub() abc js> "abc".fontcolor("blue") abc js> "abc".fontcolor("hoge") abc js> "abc".fontsize(10) abc js> "abc".anchor("hoge") abc js> "abc".link("hoge") abc !2006-07-28 Fri js> String.fromCharCode() js> String.fromCharCode(97) a js> String.fromCharCode(97, 98, 99) abc !2006-07-27 Thu js> "abc".charCodeAt(0) 97 js> "abc".charCodeAt(-1) NaN js> "abc".charCodeAt(10) NaN js> "あ".charCodeAt(0) 164 !2006-07-26 Wed js> "foo".search(/\w+/) 0 js> "foo".search(/\d+/) -1 js> "foo1".search(/\d+/) 3 js> "foo bar".search(/(\S+)\s+(\S+)/) 0 !2006-07-25 Tue js> "foo".match(/\w+/) foo js> "foo".match(/\d+/) null js> "foo1".match(/\d+/) 1 js> "foo bar".match(/(\S+)\s+(\S+)/) foo bar,foo,bar js> a = "foo bar".match(/(\S+)\s+(\S+)/) foo bar,foo,bar js> a[0] foo bar js> a[1] foo js> a[2] bar !2006-07-24 Mon js> "abcabc".lastIndexOf("a") 3 js> "abcabc".lastIndexOf("a", 1) 0 js> "abcabc".lastIndexOf("d") -1 js> "abcabc".lastIndexOf("a", 10) 3 js> "abcabc".lastIndexOf("a", -1) 0 !2006-07-23 Sun js> "abcabc".indexOf("a") 0 js> "abcabc".indexOf("a", 1) 3 js> "abcabc".indexOf("d") -1 js> "abcabc".indexOf("a", 10) -1 js> "abcabc".indexOf("a", -1) 0 !2006-07-22 Sat js> "FOO".toLowerCase() foo js> x = "FOO"; x.toLowerCase(); x FOO !2006-07-21 Fri js> "foo".toUpperCase() FOO js> x = "foo"; x.toUpperCase(); x foo !2006-07-20 Thu js> "foo".replace("f", "b") boo js> x = "foo"; x.replace("f", "b") boo js> x foo js> "foo1".replace(/\d+/, "") foo !2006-07-19 Wed js> "foo".concat("bar") foobar js> x = "foo" foo js> x.concat("bar") foobar js> x foo うむ。 !2006-07-18 Tue js> "foo bar baz".split() foo bar baz js> "foo bar baz".split(" ") foo,bar,baz js> "foo bar baz".split(" ") foo,,bar,,baz js> "foo bar baz".split(" ", 1) foo js> a = "foo bar baz".split(" ") foo,bar,baz js> a[0] foo js> a[1] bar js> a[2] baz js> a[3] !2006-07-17 Mon js> "abc".substr(0) abc js> "abc".substr(1) bc js> "abc".substr(2) c js> "abc".substr(0, 1) a js> "abc".substr(0, 2) ab js> "abc".substr(0, 5) abc js> "abc".substr(1, 0) js> "abc".substr(1, 1) b js> "abc".substr(1, 2) bc js> "abc".substr(-1, 2) c js> "abc".substr(-1) c js> "abc".substr(-2) bc js> "abc".substr(-5) abc js> "abc".substr(-5, 1) a js> "abc".substr(-5, 2) ab !2006-07-16 Sun js> "abc".slice(0, 1) a js> "abc".slice(0, 2) ab js> "abc".slice(0, 3) abc js> "abc".slice(0, 4) abc js> "abc".slice(0, -1) ab js> "abc".slice(0, -2) a js> "abc".slice(-1) c js> "abc".slice(-1, -2) js> "abc".slice(-2, -1) b 微妙な… !2006-07-15 Sat js> "abc".substring(0, 1) a js> "abc".substring(0, 2) ab js> "abc".substring(1, 0) a js> "abc".substring(1) bc js> "abc".substring(1, 1) js> "abc".substring(1, 2) b js> "abc".substring(1, 3) bc js> "abc".substring(1, 4) bc js> "abc".substring(1, -1) a js> "abc".substring(1, -2) a js> "abc".substring(-1, 1) a js> "abc".substring(-1, 2) ab js> "abc".substring(-1, 3) abc js> "abc".substring(0) abc js> "abc".substring(-1) abc !2006-07-14 Fri js> "abc".charAt(0) a js> "abc".charAt(-1) js> "abc".charAt(4) js> "あいう".charAt(0) js> "あいう".charAt(1) !2006-07-13 Thu js> "foo".length 3 js> "あ".length 2 js> "\u3042".length 1 !2006-07-12 Wed js> "あ" あ js> "表" 表 js> String("foo") foo js> new String("foo") foo js> typeof(String("foo")) string js> typeof(new String("foo")) object js> typeof("foo") string js> (new String("foo")).length 3 !2006-07-11 Tue js> "foo" foo js> "foo\tbar" foo bar js> 'foo\tbar' foo bar !2006-07-10 Mon js> Number(10/3).toPrecision(3) 3.33 js> Number(10/3).toPrecision() 3.3333333333333335 !2006-07-09 Sun js> Number(10/3).toExponential(3) 3.333e+0 js> Number(10/3).toExponential() 3.3333333333333335e+0 !2006-07-08 Sat js> 10/3 3.3333333333333335 js> Number(10/3).toFixed(3) 3.333 js> Number(10/3).toFixed() 3 !2006-07-07 Fri js> 1.valueOf() 1: SyntaxError: missing ; before statement: 1: 1.valueOf() 1: ..^ js> x = 1; x.valueOf() 1 js> Number(1).valueOf() 1 !2006-07-06 Thu js> Number.MAX_VALUE 1.7976931348623157e+308 js> Number.MIN_VALUE 5e-324 js> Number.POSITIVE_INFINITY Infinity js> Number.NEGATIVE_INFINITY -Infinity !2006-07-05 Wed js> Number.NaN NaN js> NaN NaN js> Number.NaN == NaN false js> Number.NaN == Number.NaN false js> isNaN(Number.NaN) true js> isNaN(NaN) true !2006-07-04 Tue js> 10.toString(2) 3: SyntaxError: missing ; before statement: 3: 10.toString(2) 3: ...^ js> x = 10; x.toString(2) 1010 js> x = 10; x.toString(8) 12 js> x = 10; x.toString(16) a !2006-07-03 Mon js> "3" - 0 3 js> "3" 3 js> "abc" abc !2006-07-02 Sun js> new Number(1) 1 js> typeof(1) number js> typeof(new Number(1)) object !2006-07-01 Sat js> taint() 1: ReferenceError: taint is not defined js> untaint() 2: ReferenceError: untaint is not defined !2006-06-30 Fri js> eval("1+2+3") 6 !2006-06-29 Thu js> isFinite(1) true js> isFinite(999999999999999999999999) true js> isFinite("a") false js> Math.log(0) -Infinity js> isFinite(Math.log(0)) false !2006-06-28 Wed js> isNaN(1) false js> isNaN(parseInt("A")) true js> isNaN("a") true !2006-06-27 Tue js> unescape(escape(" %+")) %+ js> unescape(escape(escape("あいう"))) %A4%A2%A4%A4%A4%A6 !2006-06-26 Mon js> escape(" %+") %20%25+ js> escape("あいう") %A4%A2%A4%A4%A4%A6 !2006-06-25 Sun js> String(1) 1 js> String(1.2) 1.2 js> String(1.2e-2) 0.012 !2006-06-24 Sat js> parseInt("1") 1 js> parseInt("1a") 1 js> parseInt("1.2") 1 js> parseInt("A") NaN js> parseInt("0x1") 1 js> parseInt("0x10") 16 js> parseInt("010") 8 js> parseInt("10", 10) 10 js> parseInt("10", 8) 8 js> parseInt("10", 16) 16 !2006-06-23 Fri js> parseFloat("1.2") 1.2 js> parseFloat("123") 123 js> parseFloat("1.2e-3") 0.0012 js> parseFloat("1.2a") 1.2 js> parseFloat("0x1") 0 js> parseFloat("A") NaN !2006-06-22 Thu js> Number(1) 1 js> Number("1") 1 js> Number("1+2") NaN js> Number("2006-06-22") NaN js> Number(1 + "2") 12 js> Number("2" - 0 + 1) 3 js> Number(new Date()) 1150945972227 !2006-06-21 Wed js> true true js> false false js> null null js> undefined js> NaN NaN js> Infinity Infinity !2006-06-20 Tue js> "foo" foo js> 'foo' foo !2006-06-19 Mon js> 1 1 js> 1.2 1.2 js> 1.2e3 1200 js> 1.2e-3 0.0012 js> 010 8 js> 0x10 16 js> 0x01e1 481 ? !2006-06-18 Sun js> !0 true js> !"0" false js> !"" true js> !1 false js> !"1" false 下手すると、はまる? js> "0" & "0" 0 js> "1" & "1" 1 !2006-06-17 Sat js> x = 1 1 js> x += 2 3 js> x 3 js> x = 1; x -= 2; x -1 js> x = 2; x *= 3; x 6 js> x = 10; x /= 3; x 3.3333333333333335 js> x = 10; x %= 3; x 1 js> x = 7; x &= 3 3 js> x = 7; x |= 3 7 js> x = 7; x ^= 3 4 js> x = 3; x <<= 1 6 js> x = 3; x >>= 1 1 js> x = 0xffffffff; x >>>= 30 3 js> x = 0xffffffff; x >>= 30 -1 !2006-06-16 Fri js> 1 << 2 4 js> 7 >> 1 3 js> 7 >>> 1 3 js> 0xffffffff >> 1 -1 js> 0xffffffff >>> 1 2147483647 js> 0xffffffff >>> 30 3 js> 0xffffffff >> 30 -1 js> "1" << "2" 4 js> "7" >> "1" 3 js> "7" >>> "1" 3 !2006-06-15 Thu js> 15 & 7 7 js> 15 | 7 15 js> 15 ^ 7 8 js> ~15 -16 js> "15" & "7" 7 js> "15" | "7" 15 js> "15" ^ "7" 8 js> ~"15" -16 !2006-06-14 Wed js> 1, 2 2 js> 1, 2, 3 3 js> x = 1, 2 2 js> x 1 !2006-06-13 Tue js> true ? "foo" : "bar" foo js> false ? "foo" : "bar" bar !2006-06-12 Mon js> !true false js> !false true !2006-06-11 Sun js> true || false true js> false || false false !2006-06-10 Sat js> true && true true js> true && false false !2006-06-09 Fri js> 1 == "1" true js> 1 === "1" false js> 1 != "2" true js> 1 !== "2" true !2006-06-08 Thu js> "abc" <= "abc" true js> "def" <= "abc" false !2006-06-07 Wed js> 1 <= 1 true js> 1 <= 2 true js> 2 <= 1 false !2006-06-06 Tue js> "foo" == "foo"; true js> "foo" == "bar"; false js> "foo" != "foo"; false js> "foo" != "bar"; true !2006-06-05 Mon js> 1 == 1; true js> 1 == 2; false js> 1 != 1; false js> 1 != 2; true !2006-06-04 Sun js> x = 1; 1 js> x++; 1 js> x 2 js> x = 1; 1 js> ++x; 2 js> x 2 js> x = 1; 1 js> x--; 1 js> x 0 !2006-06-03 Sat js> "foo" + "bar"; foobar js> "foo" * 3; NaN !2006-06-02 Fri js> 1 + 2; 3 js> 1 - 2; -1 js> 2 * 3; 6 js> 4 / 2; 2 js> 10 % 3; 1 js> 10 % -3; 1 !2006-06-01 Thu js> x = 1; 1 js> x 1