{"id":3085,"date":"2013-10-15T20:56:53","date_gmt":"2013-10-15T11:56:53","guid":{"rendered":"https:\/\/gunmagisgeek.com\/wordpress\/?p=3085"},"modified":"2013-12-29T21:16:00","modified_gmt":"2013-12-29T12:16:00","slug":"post-3085","status":"publish","type":"post","link":"https:\/\/gunmagisgeek.com\/blog\/javascript\/3085","title":{"rendered":"JavaScript\u306eWith\u6587\u3092\u4f7f\u3063\u3061\u3083\u3044\u3051\u306a\u3044\u8a33"},"content":{"rendered":"<p><a href=\"http:\/\/www.amazon.co.jp\/gp\/product\/4873113911\/ref=as_li_ss_il?ie=UTF8&#038;camp=247&#038;creative=7399&#038;creativeASIN=4873113911&#038;linkCode=as2&#038;tag=toriaezu04b-22\"><img decoding=\"async\" border=\"0\" src=\"http:\/\/ws-fe.amazon-adsystem.com\/widgets\/q?_encoding=UTF8&#038;ASIN=4873113911&#038;Format=_SL110_&#038;ID=AsinImage&#038;MarketPlace=JP&#038;ServiceVersion=20070822&#038;WS=1&#038;tag=toriaezu04b-22\" ><\/a><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/ir-jp.amazon-adsystem.com\/e\/ir?t=toriaezu04b-22&#038;l=as2&#038;o=9&#038;a=4873113911\" width=\"1\" height=\"1\" border=\"0\" alt=\"\" style=\"border:none !important; margin:0px !important;\" \/><\/p>\n<p>\u300c<a href=\"http:\/\/www.amazon.co.jp\/gp\/product\/4873113911\/ref=as_li_ss_tl?ie=UTF8&#038;camp=247&#038;creative=7399&#038;creativeASIN=4873113911&#038;linkCode=as2&#038;tag=toriaezu04b-22\">JavaScript: The Good Parts<\/a>\u300d\u306e\u4e2d\u3067\u300cWith\u6587\u4f7f\u3046\u3093\u3058\u3083\u306d\u3047\u3088\u3001\u30dc\u30b1\uff01\u300d\u3068\u6012\u3089\u308c\u305f\u3053\u3068\u306f\u899a\u3048\u3066\u3044\u308b\u306e\u3060\u3051\u308c\u3069\u3001\u3053\u306e\u524d\u5510\u7a81\u306b\u7406\u7531\u3092\u805e\u304b\u308c\u3066\u601d\u3044\u51fa\u305b\u306a\u304b\u3063\u305f\u306e\u3067\u304a\u3055\u3089\u3044\u3057\u3066\u304a\u304f\u3002<\/p>\n<p>\u7406\u7531\uff1awith\u6587\u306e\u4e2d\u3067\u8a72\u5f53\u3057\u306a\u3044\u30d7\u30ed\u30d1\u30c6\u30a3\u3084\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3076\u3068\u3001\u30d7\u30ed\u30c8\u30bf\u30a4\u30d7\u3092\u3055\u304b\u306e\u307c\u3063\u3066\u63a2\u3057\u306b\u884c\u304f\u304b\u3089\u3002<\/p>\n<p><strong>\u30b5\u30f3\u30d7\u30eb\uff11<\/strong><\/p>\n<pre class=\"lang:js decode:true \" >var p3 = &quot;hoge&quot;;\r\n\r\n(function(){\r\n\tvar obj = {\r\n\t\tp1: &quot;Hello&quot;,\r\n\t\tp2: &quot;World&quot;\r\n\t}\r\n\t\r\n\twith(obj){\r\n\t\tconsole.log(p1);\r\n\t\tconsole.log(p2);\r\n\t\tconsole.log(p3); \/\/&lt;- \u5b58\u5728\u3057\u306a\u3044\u306f\u305a\u306a\u3093\u3060\u3051\u3069\u2026\u2026\r\n\t}\r\n})();<\/pre>\n<p>p3\u306f\u5b58\u5728\u3057\u306a\u3044\u306f\u305a\u306a\u3093\u3060\u3051\u3069\u3001\u30d7\u30ed\u30c8\u30bf\u30a4\u30d7\u3092\u3055\u304b\u306e\u307c\u3063\u3066\u5916\u5074\u306e\u5909\u6570p3\u3092\u547c\u3073\u51fa\u3057\u3061\u3083\u3046\u3002<br \/>\n\u30d7\u30ed\u30d1\u30c6\u30a3\u3078\u306e\u4ee3\u5165\u3084\u3001\u30e1\u30bd\u30c3\u30c9\u306e\u547c\u3073\u51fa\u3057\u3092\u9593\u9055\u3048\u308b\u3068\u3055\u3089\u306b\u60b2\u60e8\u3002<\/p>\n<p><strong>\u30b5\u30f3\u30d7\u30eb\uff12<\/strong><\/p>\n<pre class=\"lang:js decode:true \" >\r\n(function(){\r\n\tvar btn = document.getElementById('btn');\r\n\tvar modal = {\r\n\t\tshow:function(){ alert('\u958b\u304f\u3088'); },\r\n\t\tcloze:function(){ alert('\u9589\u3058\u308b\u3088') }\r\n\t}\r\n\r\n\tbtn.addEventListener('click', function(){\r\n\t\twith(modal){\r\n\t\t\tshow();\r\n\t\t\tclose(); \/\/&lt;- window.close()\u304c\u547c\u3070\u308c\u3061\u3083\u3046\u3002\r\n\t\t}\r\n\t})\r\n\r\n})();<\/pre>\n<p>modal\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306eclose\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3073\u51fa\u3057\u305f\u306f\u305a\u304c\u3001\u30bf\u30a4\u30dd\u3057\u3066\u3044\u308b\u305b\u3044\u3067\u6b63\u3057\u304f\u547c\u3070\u308c\u305a\u3001\u30d7\u30ed\u30c8\u30bf\u30a4\u30d7\u3092\u3055\u304b\u306e\u307c\u3063\u3066\u63a2\u3057\u305f\u7d50\u679c\u3001\u6700\u7d42\u7684\u306bwindow.close()\u304c\u5b9f\u884c\u3055\u308c\u3066\u3001\u30d6\u30e9\u30a6\u30b6\u30a6\u30a4\u30f3\u30c9\u304c\u9589\u3058\u308b orz<\/p>\n<p>\u5834\u5408\u306b\u3088\u3063\u3066\u306f\u3001\u975e\u5e38\u306b\u898b\u3064\u3051\u306b\u304f\u3044\u30d0\u30b0\u306e\u6e29\u5e8a\u3068\u306a\u308b\u3053\u3068\u304c\u3042\u308b\u306e\u3067\u3001with\u6587\u3092\u4f7f\u3046\u3068\u304d\u306f\u91cd\u3005\u6ce8\u610f\u3057\u3066\u4f7f\u3044\u307e\u3057\u3087\u3046\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u300cJavaScript: The Good Par&hellip;<\/p>\n","protected":false},"author":1,"featured_media":3086,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-3085","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript","has-post-thumbnail-archive"],"_links":{"self":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/3085","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/comments?post=3085"}],"version-history":[{"count":0,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/3085\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/media\/3086"}],"wp:attachment":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/media?parent=3085"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/categories?post=3085"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/tags?post=3085"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}