{"id":1257,"date":"2014-11-25T00:37:27","date_gmt":"2014-11-24T15:37:27","guid":{"rendered":"http:\/\/tech.akat.info\/?p=1257"},"modified":"2014-12-23T16:14:45","modified_gmt":"2014-12-23T07:14:45","slug":"javascript","status":"publish","type":"post","link":"https:\/\/tech.akat.info\/?p=1257","title":{"rendered":"JavaScript"},"content":{"rendered":"<h1>\u6982\u8981<\/h1>\n<p>\u30c9\u30c3\u30c8\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3067JavaScript\u306b\u3064\u3044\u3066\u3084\u3063\u3066\u307f\u305f<br \/>\nhttp:\/\/dotinstall.com\/lessons\/basic_javascript_v2<\/p>\n<h1>\u7279\u5fb4<\/h1>\n<p>\u30d6\u30e9\u30a6\u30a6\u30b6\u306b\u5b9f\u88c5\u3055\u308c\u3066\u3044\u308b\u30b9\u30af\u30ea\u30d7\u30c8\u8a00\u8a9e<\/p>\n<h1>\u304b\u3044\u3066\u307f\u308b<\/h1>\n<h2>hello world<\/h2>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nroot@www27032ue:\/var\/www\/htdocs\/study# cat index.html\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html lang=&quot;ja&quot;&gt;\r\n&lt;head&gt;\r\n        &lt;meta charset=&quot;utf-8&quot;&gt;\r\n        &lt;title&gt;JavaScript\u306e\u7df4\u7fd2&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n        &lt;script&gt;\r\n                \/\/ \u30b3\u30e1\u30f3\u30c8\r\n                console.log(&quot;hello world!&quot;);\r\n        &lt;\/script&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>[F12]\u3067\u7ba1\u7406\u8005\u30c4\u30fc\u30eb\u3092\u8d77\u52d5\u3057\u3001\u51fa\u529b\u3092\u78ba\u8a8d\u3067\u304d\u308b<br \/>\n<a href=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/11\/2014-11-24_233326.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/11\/2014-11-24_233326.png\" alt=\"2014-11-24_233326\" width=\"631\" height=\"444\" class=\"alignnone size-full wp-image-1258\" \/><\/a><\/p>\n<h2>\u5909\u6570<\/h2>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nroot@www27032ue:\/var\/www\/htdocs\/study# cat index.html\r\n### \u4ee5\u4e0b\u30d8\u30c3\u30c0\u306f\u7701\u7565\u3059\u308b ###\r\n&lt;body&gt;\r\n        &lt;script&gt;\r\n        \/*\r\n                \u5909\u6570\r\n                - \u6587\u5b57\u5217\r\n                - \u6570\u5024\r\n                - \u771f\u507d\u5024\r\n                - \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\r\n                \u3000- \u914d\u5217\u30fb\u95a2\u6570\u30fb\u7d44\u307f\u8fbc\u307f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\r\n                - undefined \u5b9a\u7fa9\u3055\u308c\u3066\u3044\u306a\u3044\r\n                - null \u4f55\u3082\u306a\u3044\r\n        *\/\r\n\r\n                \/\/ var msg  = &quot;hello world!&quot; \u3068\u3044\u3046\u66f8\u304d\u65b9\u3082\u53ef\u80fd\r\n                \/\/ &quot;(\u30c0\u30d6\u30eb\u30af\u30aa\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3)\u3067\u3082'(\u30b7\u30f3\u30b0\u30eb\u30af\u30aa\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3)\u3067\u3082\u9055\u3044\u306f\u306a\u3044\r\n                \/\/ \u6539\u884c\u306f\\n\u3092\u5229\u7528\u3059\u308b\r\n                var msg;\r\n                msg = &quot;hello world!&quot;;\r\n                console.log(msg);\r\n        &lt;\/script&gt;\r\n&lt;\/body&gt;\r\n<\/pre>\n<h2>\u6570\u5024\u8a08\u7b97<\/h2>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nroot@www27032ue:\/var\/www\/htdocs\/study# cat index.html\r\n&lt;body&gt;\r\n        &lt;script&gt;\r\n                var x;\r\n                x = 10 * 2;\r\n                x = 10 % 3;\r\n                console.log(x);\r\n        &lt;\/script&gt;\r\n&lt;\/body&gt;\r\n<\/pre>\n<h2>\u6761\u4ef6\u5206\u5c90<\/h2>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nroot@www27032ue:\/var\/www\/htdocs\/study# cat index.html\r\n&lt;body&gt;\r\n        &lt;script&gt;\r\n                var score = 55;\r\n                if (score &gt; 60){\r\n                        console.log(&quot;OK&quot;);\r\n                } else if (score &gt; 40){\r\n                        console.log(&quot;soso...&quot;);\r\n                } else {\r\n                        console.log(&quot;NG&quot;);\r\n                }\r\n        &lt;\/script&gt;\r\n&lt;\/body&gt;\r\n<\/pre>\n<h2>\u771f\u507d\u5024<\/h2>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nif (x) {\r\n\r\n}\r\n\r\n### x\u304c\u6587\u5b57\u5217\u306e\u5834\u5408\u3001\u4e0a\u306f\u4ee5\u4e0b\u3068\u540c\u7fa9 ###\r\nif (x !== ''){\r\n\r\n}\r\n\r\n<\/pre>\n<h2>while\u6587<\/h2>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nvar i = 0;\r\nwhile ( i &lt; 10){\r\n        console.log(i);\r\n        i++;\r\n}\r\n<\/pre>\n<h2>\u30e6\u30fc\u30b6\u306b\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u8868\u793a\u3059\u308b<\/h2>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n\/\/ alert\u306e\u8868\u793a\r\nalert(&quot;hello&quot;);\r\n\r\n\/\/ cancel\u30dc\u30bf\u30f3\u304c\u3064\u3044\u3066\u3044\u308b\r\nvar answer = confirm(&quot;are you sure?&quot;);\r\nconsole.log(answer);\r\n\r\n\/\/ \u5909\u6570\u3092\u683c\u7d0d\u3059\u308b\r\nvar name = prompt(&quot;what's your name?&quot;,&quot;\u540d\u7121\u3057&quot;)\r\nconsole.log(name);\r\n<\/pre>\n<p><a href=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/11\/2014-12-22_214246.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/11\/2014-12-22_214246.png\" alt=\"2014-12-22_214246\" width=\"525\" height=\"283\" class=\"alignnone size-full wp-image-1328\" \/><\/a><\/p>\n<h2>\u95a2\u6570<\/h2>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n\/\/ \u5f15\u6570\u3092\u6301\u305f\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u308b\r\nfunction hello(name) {\r\n        console.log(&quot;hello&quot; + name);\r\n}\r\n\r\nhello(&quot;Tom&quot;);\r\n\r\n\/\/ \u8fd4\u308a\u5024\u3092\u3082\u305f\u305b\u308b\u3053\u3068\u3082\u3067\u304d\u308b\r\nfunction hello2(name){\r\n        return &quot;hello&quot; + name;\r\n}\r\nvar greet = hello2(&quot;John&quot;);\r\nconsole.log(greet);\r\n<\/pre>\n<h2>\u95a2\u6570\u305d\u306e2<\/h2>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n\/\/ \u95a2\u6570\u3082\u30c7\u30fc\u30bf\u578b\u3067\u3042\u308b\u305f\u3081\u5909\u6570\u306b\u5165\u308c\u308b\u3053\u3068\u304c\u53ef\u80fd\r\nvar varhello = function(name) {\r\n        var msg = &quot;hello&quot; + name;\r\n        return msg;\r\n};\r\nvar greet = varhello(&quot;John&quot;);\r\nconsole.log(greet);\r\n<\/pre>\n<h2>\u95a2\u6570\u305d\u306e3<\/h2>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n\/\/ \u5373\u6642\u95a2\u6570\u3002\u5b9a\u7fa9\u3057\u3066\u5373\u5b9f\u884c\u3059\u308b\r\n(function hello(name) { \/\/ hello\u3092\u7701\u7565\u3059\u308b\u3053\u3068\u3082\u53ef\r\n        console.log(&quot;hello &quot;+name);\r\n})(&quot;Tom&quot;);\r\n<\/pre>\n<h2>\u30bf\u30a4\u30de\u30fc\u51e6\u7406<\/h2>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n\/\/ setInterval : \u4e00\u5b9a\u9593\u9694\u3067\u51e6\u7406\u3092\u5b9f\u884c\u3002\u524d\u306e\u51e6\u7406\u304c\u7d42\u308f\u3063\u3066\u3044\u308b\u304b\u3069\u3046\u304b\u306f\u6c17\u306b\u3057\u306a\u3044\r\n\/\/ setTimeout : \u4e00\u5b9a\u6642\u9593\u7d4c\u3064\u3068\u3001\u4e00\u5ea6\u3060\u3051\u51e6\u7406\u3092\u5b9f\u884c\u3002\u3002\u524d\u306e\u51e6\u7406\u304c\u5b8c\u4e86\u3057\u3066\u3044\u308b\u3068\u5b9f\u884c\u3059\u308b\r\nvar i = 0;\r\nfunction show() {\r\n        console.log(i++);\r\n}\r\n\r\nsetInterval(function(){\r\n        show();\r\n},1000);\r\n<\/pre>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n\/\/ 3\u3092\u8868\u793a\u3057\u305f\u3089\u7d42\u4e86\u3059\u308b\r\nvar i = 0;\r\nfunction show() {\r\n        console.log(i++);\r\n        var tid = setTimeout(function(){\r\n                show();\r\n        },1000);\r\n        if (i &gt; 3){\r\n                clearTimeout(tid);\r\n        }\r\n}\r\nshow();\r\n<\/pre>\n<h2>\u914d\u5217<\/h2>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nvar score = &#x5B;100, 300, 500];\r\nconsole.log(score&#x5B;0]);\r\nconsole.log(score);\r\n<\/pre>\n<p><a href=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/11\/2014-12-22_225338.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/11\/2014-12-22_225338.png\" alt=\"2014-12-22_225338\" width=\"555\" height=\"142\" class=\"alignnone size-full wp-image-1330\" \/><\/a><\/p>\n<h2>\u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/h2>\n<p>\u540d\u524d\u3068\u5024\u304c\u30b0\u30eb\u30fc\u30d7\u5316\u3055\u308c\u3066\u3044\u308b<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nvar user = {\r\n        email: &quot;shimizu.r.hiroaki@gmail.com&quot;,\r\n        score: 80\r\n};\r\n\r\nconsole.log(user&#x5B;&quot;email&quot;]);\r\nconsole.log(user.score);\r\nconsole.log(user);\r\n<\/pre>\n<p><a href=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/11\/2014-12-22_225850.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/11\/2014-12-22_225850.png\" alt=\"2014-12-22_225850\" width=\"597\" height=\"163\" class=\"alignnone size-full wp-image-1331\" \/><\/a><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nvar user = {\r\n        email: &quot;shimizu.r.hiroaki@gmail.com&quot;,\r\n        score: 80,\r\n        greet: function(name) { \/\/ \u95a2\u6570\u306e\u3053\u3068\u3092\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30e1\u30bd\u30c3\u30c9\u3002this\u3067\u81ea\u5206\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u6307\u3059\r\n                console.log(&quot;hello,&quot; + name + &quot; from &quot; + this.email);\r\n        }\r\n};\r\nuser.greet(&quot;Tom&quot;);\r\n<\/pre>\n<p><a href=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/11\/2014-12-22_230945.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/11\/2014-12-22_230945.png\" alt=\"2014-12-22_230945\" width=\"683\" height=\"149\" class=\"alignnone size-full wp-image-1332\" \/><\/a><\/p>\n<h2>\u7d44\u307f\u8fbc\u307f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/h2>\n<p>javascript\u304c\u7528\u610f\u3057\u3066\u3044\u308b\u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/p>\n<pre class=\"brush: plain; title: String; notranslate\" title=\"String\">\r\nvar s = new String(&quot;shimizu&quot;);\r\n\/\/ \u5b9f\u306f\u3001var s = &quot;shimizu&quot;; \u3067\u3082\u540c\u3058\u3053\u3068\u304c\u3067\u304d\u308b(\u6587\u5b57\u5217\u30ea\u30c6\u30e9\u30eb)\r\nconsole.log(s.length);\r\nconsole.log(s.replace(&quot;i&quot;,&quot;I&quot;));\r\n<\/pre>\n<pre class=\"brush: plain; title: Date; notranslate\" title=\"Date\">\r\nvar d = new Date(2014, 1, 11, 10 ,20 ,30);\r\nconsole.log(d.getFullYear());\r\nconsole.log(d.getMonth());\r\n<\/pre>\n<h2>DOM<\/h2>\n<p>\u30d6\u30e9\u30a6\u30b6\u81ea\u8eab\u3082\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3067\u3042\u308a\u3001\u64cd\u4f5c\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n\/\/ \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u8868\u793a\r\nconsole.dir(window);\r\n<\/pre>\n<p>window.document &#8211; \u4eca\u958b\u3044\u3066\u3044\u308b\u30da\u30fc\u30b8\u306e\u3053\u3068<br \/>\nJavascript\u3067\u66f8\u304d\u63db\u3048\u308b\u3053\u3068\u3067\u52d5\u7684\u306b\u30da\u30fc\u30b8\u3092\u5909\u66f4\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b<br \/>\ndocument \u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u305f\u3081\u306e\u547d\u4ee4\u3092document object model (DOM)\u3068\u547c\u3076<br \/>\n\u4ee5\u4e0b\u306b\u3064\u3044\u3066\u3001\u6587\u5b57\u5217\u3068\u8272\u3092\u5909\u66f4\u3057\u3066\u3044\u308b<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html lang=&quot;ja&quot;&gt;\r\n&lt;head&gt;\r\n        &lt;meta charset=&quot;utf-8&quot;&gt;\r\n        &lt;title&gt;JavaScript\u306e\u7df4\u7fd2&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n        &lt;h1&gt;\u898b\u51fa\u3057&lt;\/h1&gt;\r\n        &lt;p id=&quot;msg&quot;&gt;\u3053\u3093\u306b\u3061\u306f&lt;\/p&gt;\r\n        &lt;script&gt;\r\n        var e = document.getElementById('msg');\r\n        e.textContent = 'hello!';\r\n        e.style.color = 'red';\r\n\r\n        &lt;\/script&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p><a href=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/11\/2014-12-23_113738.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/11\/2014-12-23_113738.png\" alt=\"2014-12-23_113738\" width=\"477\" height=\"235\" class=\"alignnone size-full wp-image-1333\" \/><\/a><\/p>\n<h2>\u30a4\u30d9\u30f3\u30c8<\/h2>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html lang=&quot;ja&quot;&gt;\r\n&lt;head&gt;\r\n        &lt;meta charset=&quot;utf-8&quot;&gt;\r\n        &lt;title&gt;JavaScript\u306e\u7df4\u7fd2&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n        &lt;h1&gt;\u898b\u51fa\u3057&lt;\/h1&gt;\r\n        &lt;p id=&quot;msg&quot;&gt;\u3053\u3093\u306b\u3061\u306f&lt;\/p&gt;\r\n        &lt;button id=&quot;add&quot;&gt;click&lt;\/button&gt;\r\n        &lt;script&gt;\r\n        document.getElementById('add').addEventListener('click',function(){\r\n        var e = document.getElementById('msg');\r\n        e.textContent = 'hello!';\r\n        e.style.color = 'red';\r\n        });\r\n        &lt;\/script&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>\u30dc\u30bf\u30f3\u3092\u62bc\u3059\u3068\u300c\u3053\u3093\u306b\u3061\u306f\u300d\u306e\u6587\u5b57\u3068\u8272\u304c\u5909\u5316\u3059\u308b<br \/>\n<a href=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/11\/2014-12-23_114144.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/11\/2014-12-23_114144.png\" alt=\"2014-12-23_114144\" width=\"412\" height=\"239\" class=\"alignnone size-full wp-image-1334\" \/><\/a><\/p>\n<h2>\u304a\u307f\u304f\u3058\u3092\u4f5c\u308b<\/h2>\n<p>http:\/\/dotinstall.com\/lessons\/omikuji_js<br \/>\n<a href=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/11\/2014-12-23_161114.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/11\/2014-12-23_161114.png\" alt=\"2014-12-23_161114\" width=\"385\" height=\"193\" class=\"alignnone size-full wp-image-1336\" \/><\/a><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html lang=&quot;ja&quot;&gt;\r\n&lt;head&gt;\r\n        &lt;meta charset=&quot;utf-8&quot;&gt;\r\n        &lt;title&gt;\u304a\u307f\u304f\u3058&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n        &lt;h1&gt;\u304a\u307f\u304f\u3058&lt;\/h1&gt;\r\n        &lt;input type=&quot;button&quot; value=&quot;\u3042\u306a\u305f\u306e\u904b\u52e2\u306f&quot; onclick=&quot;getOmikuji();&quot;&gt;\r\n        &lt;p&gt;\u3042\u306a\u305f\u306e\u904b\u52e2\u306f...&lt;span id=&quot;result&quot;&gt;&lt;\/span&gt;&lt;\/p&gt;\r\n        &lt;script&gt;\r\n                function getOmikuji(){\r\n                        var omikuji = &#x5B;&quot;\u5927\u5409&quot;,&quot;\u4e2d\u5409&quot;,&quot;\u5c0f\u5409&quot;];\r\n                        var result = Math.floor(Math.random() * omikuji.length);\r\n                        document.getElementById('result').innerHTML = omikuji&#x5B;result];\r\n                }\r\n        &lt;\/script&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<h2>\u30b9\u30ed\u30c3\u30c8\u30de\u30b7\u30fc\u30f3<\/h2>\n<p><a href=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/11\/2014-12-23_161226.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/11\/2014-12-23_161226.png\" alt=\"2014-12-23_161226\" width=\"466\" height=\"256\" class=\"alignnone size-full wp-image-1337\" \/><\/a><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html lang=&quot;ja&quot;&gt;\r\n&lt;head&gt;\r\n        &lt;meta charset=&quot;utf-8&quot;&gt;\r\n        &lt;title&gt;\u30b9\u30ed\u30c3\u30c8\u30de\u30b7\u30fc\u30f3&lt;\/title&gt;\r\n        &lt;style&gt;\r\n        .col{\r\n        float: left;\r\n        width: 100px;\r\n        text-align: center;\r\n        font-size: 32px;\r\n        }\r\n        &lt;\/style&gt;\r\n\r\n&lt;\/head&gt;\r\n\r\n&lt;body&gt;\r\n&lt;div class=&quot;col&quot;&gt;\r\n        &lt;span id=&quot;num0&quot;&gt;?&lt;\/span&gt;&lt;br&gt;\r\n        &lt;input type=&quot;button&quot; value=&quot;STOP&quot; id=&quot;stop0&quot;&gt;\r\n&lt;\/div&gt;\r\n\r\n&lt;div class=&quot;col&quot;&gt;\r\n        &lt;span id=&quot;num1&quot;&gt;?&lt;\/span&gt;&lt;br&gt;\r\n        &lt;input type=&quot;button&quot; value=&quot;STOP&quot; id=&quot;stop1&quot;&gt;\r\n&lt;\/div&gt;\r\n\r\n&lt;div class=&quot;col&quot;&gt;\r\n        &lt;span id=&quot;num2&quot;&gt;?&lt;\/span&gt;&lt;br&gt;\r\n        &lt;input type=&quot;button&quot; value=&quot;STOP&quot; id=&quot;stop2&quot;&gt;\r\n&lt;\/div&gt;\r\n\r\n&lt;script&gt;\r\n\r\n(function() {\r\nvar timers,\r\nnums,\r\nstopCount;\r\n\r\ndocument.getElementById('stop0').onclick = function() {\r\n        stopSlot(0);\r\n};\r\ndocument.getElementById('stop1').onclick = function() {\r\n        stopSlot(1);\r\n};\r\ndocument.getElementById('stop2').onclick = function() {\r\n        stopSlot(2);\r\n};\r\n\r\n\r\nfunction startSlot(){\r\n        timers = &#x5B;];\r\n        nums = &#x5B;];\r\n        stopCount = 0;\r\n\r\n        runSlot(0);\r\n        runSlot(1);\r\n        runSlot(2);\r\n\r\n}\r\n\r\nfunction stopSlot(n) {\r\n        \/\/ javascript \u7279\u6709\u306e\u66f8\u304d\u65b9\r\n        if (typeof nums&#x5B;n] !== 'undefined') {\r\n                return;\r\n        }\r\n\r\n        clearTimeout(timers&#x5B;n]);\r\n        nums&#x5B;n] = document.getElementById('num'+ n).innerHTML;\r\n        stopCount++;\r\n\r\n        if (stopCount == 3){\r\n                checkSlot();\r\n        }\r\n}\r\n\r\nfunction checkSlot() {\r\n        nums.sort();\r\n        if(nums&#x5B;0] == nums&#x5B;1] &amp;&amp; nums&#x5B;0] == nums&#x5B;2]){\r\n                alert('\u3059\u3079\u3066\u63c3\u3063\u305f');\r\n        }else if (nums&#x5B;0] == nums&#x5B;1] || nums&#x5B;1] == nums&#x5B;2]){\r\n                alert('2\u3064\u63c3\u3063\u305f');\r\n        }else{\r\n                alert('\u6b8b\u5ff5');\r\n        }\r\n}\r\n\r\nfunction runSlot(n) {\r\n        document.getElementById('num'+ n).innerHTML = Math.floor(Math.random() * 10);\r\n        timers&#x5B;n] = setTimeout(function() {\r\n        runSlot(n);},50);\r\n}\r\n\r\nstartSlot();\r\n})();\r\n\r\n&lt;\/script&gt;\r\n\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<h2>5\u79d2\u3067\u6c7a\u3081\u308d<\/h2>\n<p>http:\/\/dotinstall.com\/lessons\/just_five_js<br \/>\n<a href=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/11\/2014-12-23_160930.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/11\/2014-12-23_160930.png\" alt=\"2014-12-23_160930\" width=\"473\" height=\"207\" class=\"alignnone size-full wp-image-1335\" \/><\/a><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html lang=&quot;ja&quot;&gt;\r\n&lt;head&gt;\r\n        &lt;meta charset=&quot;utf-8&quot;&gt;\r\n        &lt;title&gt;5\u79d2\u3067\u6c7a\u3081\u308d\uff01&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n\r\n&lt;body&gt;\r\n\r\n&lt;h1&gt;5\u79d2\u3067\u6c7a\u3081\u308d\uff01&lt;\/h1&gt;\r\n&lt;p&gt;&lt;input type=&quot;button&quot; value=&quot;start&quot; onclick=&quot;start();&quot;&gt;&lt;\/p&gt;\r\n&lt;p&gt;&lt;input type=&quot;button&quot; value=&quot;stop&quot; onclick=&quot;stop();&quot;&gt;&lt;\/p&gt;\r\n&lt;p id=&quot;result&quot;&gt;&lt;\/p&gt;\r\n\r\n&lt;script&gt;\r\nvar start;\r\nvar stop;\r\nvar FIVE_SECOND = 5 * 1000;\r\nfunction start() {\r\n        start = new Date().getTime();\r\n        console.log(start);\r\n}\r\n\r\nfunction stop() {\r\n        stop = new Date().getTime();\r\n        console.log(stop);\r\n\r\n        \/\/ \u5dee\u3092\u7b97\u51fa\r\n        var diff = FIVE_SECOND - (stop - start);\r\n        \/\/ \u7d50\u679c\u3092\u8868\u793a\r\n        var e = document.getElementById('result');\r\n        if (diff == 0) {\r\n                e.innerHTML= '\u3074\u3063\u305f\u308a';\r\n        } else if (diff &gt; 0){\r\n                e.innerHTML = (diff \/ 1000) + '\u79d2\u65e9\u3044';\r\n        } else {\r\n                e.innerHTML = (diff \/ 1000) + '\u79d2\u9045\u3044';\r\n        }\r\n}\r\n&lt;\/script&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<h1>\u53c2\u8003URL<\/h1>\n<p>\u30c9\u30c3\u30c8\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb-javascript\u95a2\u9023<br \/>\nhttp:\/\/dotinstall.com\/lessons\/basic_javascript_v2<br \/>\nhttps:\/\/developer.mozilla.org\/ja\/docs\/Web\/JavaScript<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8981 \u30c9\u30c3\u30c8\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3067JavaScript\u306b\u3064\u3044\u3066\u3084\u3063\u3066\u307f\u305f http:\/\/dotinstall.com\/lessons\/basic_javascript_v2 \u7279\u5fb4 \u30d6\u30e9\u30a6\u30a6\u30b6\u306b\u5b9f\u88c5\u3055\u308c\u3066\u3044\u308b\u30b9\u30af\u30ea\u30d7\u30c8\u8a00\u8a9e \u304b\u3044\u3066 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[51],"tags":[46],"_links":{"self":[{"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/posts\/1257"}],"collection":[{"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tech.akat.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1257"}],"version-history":[{"count":5,"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/posts\/1257\/revisions"}],"predecessor-version":[{"id":1339,"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/posts\/1257\/revisions\/1339"}],"wp:attachment":[{"href":"https:\/\/tech.akat.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1257"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tech.akat.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1257"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tech.akat.info\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1257"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}