Java エンジニアのためのJavaScript講座

Java エンジニアのためのJavaScript講座

D086406794046c4dc23ab027701f6d43?s=128

Takeshi Kawajiri

April 24, 2013
Tweet

Transcript

  1. 3.
  2. 6.
  3. 7.
  4. 8.
  5. 11.

             

        ࡭ ࡭ ࡭ ࡭ ࡭ ࡭ ࡭ ࡭ ࡭ ࡭ ࡭ ࡭ ࡭ ࡭
  6. 12.
  7. 22.
  8. 23.
  9. 25.
  10. 26.
  11. 27.
  12. 28.
  13. 29.
  14. 30.
  15. 32.
  16. 33.
  17. 34.

    var a = 1; function func(b) { return a +

    b; } func(10); //=> 11 ม਺એݴ
  18. 35.

    var a = 1; function func(b) { return a +

    b; } func(10); //=> 11 ؔ਺એݴ
  19. 36.

    var a = 1; function func(b) { return a +

    b; } func(10); //=> 11 Ҿ਺ ฦΓ஋
  20. 37.

    var a = 1; function func(b) { return a +

    b; } func(10); //=> 11 ֎෦ม਺ͷࢀর
  21. 38.

    var a = 1; function func(b) { return a +

    b; } func(10); //=> 11 ؔ਺ݺͼग़͠
  22. 39.

    var a = 1; function func(b) { return a +

    b; } func(10); //=> 11 ࣝผࢠ
  23. 40.

    var a = 1; function func(b) { return a +

    b; } func(10); //=> 11 ਺஋
  24. 49.

    var n = new Number(1); n["prop1"] = 1; n["prop1"]; //=>

    1 n.prop2 = 2; n.prop2; //=>2 Ç QSPQ O  QSPQ 
  25. 51.
  26. 54.

    var obj = new Object; obj.a = 1; obj.a; //=>

    1 var obj = { a: 1 }; obj.a; //=>1
  27. 55.

    var arr = new Array; arr[0] = 1; arr[0]; //=>

    1 var arr = [1, 2]; arr[0]; //=> 1
  28. 56.

    var arr = [1, 2]; arr[100] = 3; arr.a =

    1;  BSS      B 
  29. 59.
  30. 61.
  31. 62.

    var obj = { m: function(a) { return a +

    1; } }; obj.m(1); //=> 2
  32. 64.

    var a, b = 1; a = 2; function c(d)

    { var e = 5; } c(2);
  33. 65.

    var a, b = 1; a = 2; function c(d)

    { var e = 5; } c(2);
  34. 68.

    var a, b = 1; a = 2; function c(d)

    { var e = 5; } c(2);
  35. 69.

    var a = 1; function f1() { var b =

    2; function f2() { var c = 3; }; }
  36. 71.
  37. 72.

    function My(a) { this.a = a; } My.prototype = {

    m1: function(b) { return this.a + b; } }; var my = new My(1); my.a; //=> 1 my.a = 2; my.m1(10); //=> 12
  38. 73.

    function My(a) { this.a = a; } My.prototype = {

    m1: function(b) { return this.a + b; } }; var my = new My(1); my.a; //=> 1 my.a = 2; my.m1(10); //=> 12 OFXࣜ
  39. 74.

    function My(a) { this.a = a; } My.prototype = {

    m1: function(b) { return this.a + b; } }; var my = new My(1); my.a; //=> 1 my.a = 2; my.m1(10); //=> 12 ίϯετϥΫλ
  40. 75.

    function My(a) { this.a = a; } My.prototype = {

    m1: function(b) { return this.a + b; } }; var my = new My(1); my.a; //=> 1 my.a = 2; my.m1(10); //=> 12 Πϯελϯε
  41. 76.

    function My(a) { this.a = a; } My.prototype = {

    m1: function(b) { return this.a + b; } }; var my = new My(1); my.a; //=> 1 my.a = 2; my.m1(10); //=> 12 ϓϩτλΠϓ
  42. 77.

    function My(a) { this.a = a; } My.prototype = {

    m1: function(b) { return this.a + b; } }; var my = new My(1); my.a; //=> 1 my.a = 2; my.m1(10); //=> 12 ϝιου
  43. 78.

    function My(a) { this.a = a; } My.prototype = {

    m1: function(b) { return this.a + b; } }; var my = new My(1); my.a; //=> 1 my.a = 2; my.m1(10); //=> 12
  44. 80.

    function My(a) { this.a = a; } My.prototype = {

    m1: function(b) { return this.a + b; } }; var my = new My(1); my.a; //=> 1 my.a = 2; my.m1(10); //=> 12
  45. 82.

    function My(a) { this.a = a; } My.prototype = {

    m1: function(b) { return this.a + b; } }; var my = new My(1); my.a; //=> 1 my.a = 2; my.m1(10); //=> 12 OFX0CKFDU
  46. 83.
  47. 101.

    var n = new Number(1); n instanceof Number; //=> true

    n.__proto__ = String.prototype n instanceof Number; //=> false n instanceof String; //=> true
  48. 112.
  49. 123.

    var n = new Number(1); n instanceof Number; //=> true

    n.__proto__ = String.prototype n instanceof Number; //=> false n instanceof String; //=> true
  50. 134.
  51. 135.

    function My(a) { this.a = a; } My.prototype = {

    m1: function(b) { return this.a + b; } }; var my = new My(1); my.a; //=> 1 my.a = 2; my.m1(10); //=> 12
  52. 142.

    function My(a) { this.a = a; } My.prototype = {

    m1: function(b) { return this.a + b; } }; var my = new My(1); my.a; //=> 1 my.a = 2; my.m1<<my>>(10); //=> 12
  53. 157.

    function My(a) { this.a = a; } My.prototype = {

    m1: function(b) { return this.a + b; } }; var my = new My(1); my.a; //=> 1 my.a = 2; my.m1(10); //=> 12
  54. 158.

    function My(a) { this.a = a; } My.prototype = {

    m1: function(b) { return this.a + b; } }; var my = new My(1); my.a; //=> 1 my.a = 2; my.m1(10); //=> 12
  55. 159.

    function My(a) { this.a = a; } My.prototype = {

    m1: function(b) { return this.a + b; } }; var my = new My(1); my.a; //=> 1 my.a = 2; my.m1(10); //=> 12
  56. 160.

    function My(a) { this.a = a; } My.prototype = {

    m1: function(b) { return this.a + b; } }; var my = new My(1); my.a; //=> 1 my.a = 2; my.m1(10); //=> 12
  57. 161.

    function My(a) { this.a = a; } My.prototype = {

    m1: function(b) { return this.a + b; } }; var my = new My(1); my.a; //=> 1 my.a = 2; my.m1(10); //=> 12
  58. 162.

    function My(a) { this.a = a; } My.prototype = {

    m1: function(b) { return this.a + b; } }; var my = new My(1); my.a; //=> 1 my.a = 2; my.m1(10); //=> 12
  59. 163.
  60. 164.
  61. 174.

    var a = 1; function func() { var a =

    10; return function() { return a++; }; } var b = func(); b(); //=> 10 b(); //=> 11 var c = func(); c(); //=> 10
  62. 175.

    var a = 1; function func() { var a =

    10; return function() { return a++; }; } var b = func(); b(); //=> 10 b(); //=> 11 var c = func(); c(); //=> 10
  63. 176.

    var a = 1; function func() { var a =

    10; return function() { return a++; }; } var b = func(); b(); //=> 10 b(); //=> 11 var c = func(); c(); //=> 10
  64. 177.

    var a = 1; function func() { var a =

    10; return function() { return a++; }; } var b = func(); b(); //=> 10 b(); //=> 11 var c = func(); c(); //=> 10
  65. 178.

    var a = 1; function func() { var a =

    10; return function() { return a++; }; } var b = func(); b(); //=> 10 b(); //=> 11 var c = func(); c(); //=> 10
  66. 179.

    var a = 1; function func() { var a =

    10; return function() { return a++; }; } var b = func(); b(); //=> 10 b(); //=> 11 var c = func(); c(); //=> 10
  67. 180.

    var a = 1; function func() { var a =

    10; return function() { return a++; }; } var b = func(); b(); //=> 10 b(); //=> 11 var c = func(); c(); //=> 10
  68. 181.

    var a = 1; function func() { var a =

    10; return function() { return a++; }; } var b = func(); b(); //=> 10 b(); //=> 11 var c = func(); c(); //=> 10
  69. 182.

    var a = 1; function func() { var a =

    10; return function() { return a++; }; } var b = func(); b(); //=> 10 b(); //=> 11 var c = func(); c(); //=> 10
  70. 184.

    function sum(a, b) { return a + b; } var

    left = 1; //.... var right = 2; sum(left, right);
  71. 185.

    function left(a) { return function(b) { return a + b;

    }; } var right = left(1); //..... right(2);
  72. 188.

    var a = 1; function func(refA) { var a =

    10; return refA(); } func(function() { return a; });
  73. 189.

    var a = 1; function func(refA) { var a =

    10; return refA(); }; func(function() { return a; });
  74. 196.
  75. 198.
  76. 200.
  77. 202.
  78. 204.
  79. 205.

    var a = 1; function func() { var a =

    10; return function() { return a++; }; } var b = func(); b(); //=> 10 b(); //=> 11 var c = func(); c(); //=> 10
  80. 206.

    var a = 1; function func() { var a =

    10; return function() { return a++; }; } var b = func(); b(); //=> 10 b(); //=> 11 var c = func(); c(); //=> 10
  81. 207.

    var a = 1; function func() { var a =

    10; return function() { return a++; }; } var b = func(); b(); //=> 10 b(); //=> 11 var c = func(); c(); //=> 10
  82. 208.

    var a = 1; function func() { var a =

    10; return function() { return a++; }; } var b = func(); b(); //=> 10 b(); //=> 11 var c = func(); c(); //=> 10
  83. 210.

    var a = 1; function func() { var a =

    10; return function() { return a++; }; } var b = func(); b(); //=> 10 b(); //=> 11 var c = func(); c(); //=> 10
  84. 212.

    var a = 1; function func() { var a =

    10; return function() { return a++; }; } var b = func(); b(); //=> 10 b(); //=> 11 var c = func(); c(); //=> 10
  85. 214.

    var a = 1; function func() { var a =

    10; return function() { return a++; }; } var b = func(); b(); //=> 10 b(); //=> 11 var c = func(); c(); //=> 10
  86. 216.

    var a = 1; function func() { var a =

    10; return function() { return a++; }; } var b = func(); b(); //=> 10 b(); //=> 11 var c = func(); c(); //=> 10
  87. 218.

    var a = 1; function func() { var a =

    10; return function() { return a++; }; } var b = func(); b(); //=> 10 b(); //=> 11 var c = func(); c(); //=> 10
  88. 220.

    var a = 1; function func() { var a =

    10; return function() { return a++; }; } var b = func(); b(); //=> 10 b(); //=> 11 var c = func(); c(); //=> 10
  89. 222.

    var a = 1; function func() { var a =

    10; return new Function("", "return a++;") } var b = func(); b();
  90. 223.

    var a = 1; function func(refA) { var a =

    10; return refA(); } func(function() { return a; });
  91. 224.

    var a = 1; function func(refA) { var a =

    10; return refA(); } func(function() { return a; });
  92. 225.

    var a = 1; function func(refA) { var a =

    10; return refA(); } func(function() { return a; });
  93. 226.
  94. 227.

    var a = 1; function func(refA) { var a =

    10; return refA(); } func(function() { return a; });
  95. 229.

    var a = 1; function func(refA) { var a =

    10; return refA(); } func(function() { return a; });
  96. 231.

    var a = 1; function func(refA) { var a =

    10; return refA(); } func(function() { return a; });
  97. 233.