{"id":2821,"date":"2021-04-12T18:37:05","date_gmt":"2021-04-12T09:37:05","guid":{"rendered":"https:\/\/qol-kk.com\/wp2\/?p=2821"},"modified":"2021-04-13T09:48:28","modified_gmt":"2021-04-13T00:48:28","slug":"post-2821","status":"publish","type":"post","link":"https:\/\/qol-kk.com\/wp2\/blog\/2021\/04\/12\/post-2821\/","title":{"rendered":"JavaScript\uff1a\u304a\u624b\u4f1d\u3044\u3057\u3066\u3044\u308b\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u30b9\u30af\u30fc\u30eb\u3067\u805e\u304b\u308c\u305f\u8cea\u554f\u3010this\u3063\u3066\u3069\u3053\u306e\u4e8b\uff1f\u3011"},"content":{"rendered":"<h2>JavaScript\uff1a\u304a\u624b\u4f1d\u3044\u3057\u3066\u3044\u308b\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u30b9\u30af\u30fc\u30eb\u3067\u805e\u304b\u308c\u305f\u8cea\u554f\u3010this\u3063\u3066\u3069\u3053\u306e\u4e8b\uff1f\u3011<\/h2>\n<p>\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u30b9\u30af\u30fc\u30eb\u306e\u751f\u5f92\u3055\u3093\u3068\u3044\u308d\u3044\u308d\u304a\u8a71\u3057\u3066\u3044\u308b\u4e2d\u3067\u51fa\u3066\u304d\u305f\u300e\u3088\u304f\u7406\u89e3\u3067\u304d\u306a\u304b\u3063\u305f\u4e8b\u300f\u306b\u3064\u3044\u3066\u3001\u3053\u306e\u969b\u307e\u3068\u3081\u3066\u304a\u3053\u3046\u306e\u7b2c\u56db\u5f3e\u3002<br \/>\n\u5177\u4f53\u7684\u306b\u306f\u3053\u3093\u306a\u5185\u5bb9\u3067\u3059\u3002<\/p>\n<div class=\"paperBox\">\n<ol>\n<li><a href=\"https:\/\/qol-kk.com\/wp2\/blog\/2021\/04\/04\/post-2794\/\">let \u3068 const \u3068 var \u306f\u4f55\u304c\u9055\u3046\u306e\uff1f<\/a><\/li>\n<li><a href=\"https:\/\/qol-kk.com\/wp2\/blog\/2021\/04\/05\/post-2797\/\">function\u3063\u3066\u4f55\uff1f\u3042\u308b\u6642\u3068\u306a\u3044\u6642\u3067\u4f55\u304c\u9055\u3046\u306e\uff1f<\/a><\/li>\n<li><a href=\"https:\/\/qol-kk.com\/wp2\/blog\/2021\/04\/06\/post-2810\/\">\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306f { } \u3067\u56f2\u308f\u308c\u3066\u3044\u308b\u3068\u3044\u3046\u3051\u3069\u3001function(){ } \u306e { } \u306e\u4e2d\u3082\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306a\u306e\uff1f<\/a><\/li>\n<li>this. \u3063\u3066\u3069\u3053\u3092\u6307\u3057\u3066\u3044\u308b\u306e\uff1f&lt;= \u4eca\u56de\u306f\u3053\u3053<\/li>\n<li><a href=\"https:\/\/qol-kk.com\/wp2\/blog\/2021\/04\/13\/post-2834\/\">JavaScript\u3068Java\u306f\u540c\u3058\u306a\u306e\uff1f<\/a><\/li>\n<\/ol>\n<\/div>\n<h3>this\u306e\u6307\u3059\u5834\u6240\u306f\u300c\u305d\u306e\u6642\u3005\u3067\u5909\u308f\u308b\u300d\u304b\u3089\u521d\u5fc3\u8005\u6ce3\u304b\u305b\u3067\u3042\u308b<\/h3>\n<p>\u300cthis\u3063\u3066\u4f55\u306e\u3053\u3068\uff1f\u300d\u4eca\u56de\u306e\u8cea\u554f\u306e\u4e2d\u3067\u4e00\u756a\u56de\u7b54\u306b\u56f0\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u52c9\u5f37\u3057\u3066\u3044\u3066\u6df7\u4e71\u3059\u308b\u7406\u7531\u306f\u300e\u30b0\u30ed\u30fc\u30d0\u30eb\u30b9\u30b3\u30fc\u30d7\u300f\u3068\u300e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u95a2\u6570\u300f\u3067this\u306e\u6307\u3059\u3082\u306e\u304c\u5909\u308f\u308b\u304b\u3089\u3060\u3068\u601d\u3044\u307e\u3059\u3002\u3067\u3082\u3053\u308c\u3092\u79c1\u81ea\u8eab\u304c\u521d\u5fc3\u8005\u304c\u308f\u304b\u308b\u5f62\u306e\u660e\u78ba\u306a\u8a00\u8a9e\u306b\u51fa\u6765\u306a\u3044...\u3002<br \/>\n\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u5927\u307e\u304b\u306a\u3068\u3053\u308d\u3060\u3051\u304a\u4f1d\u3048\u3057\u3066\u6b63\u78ba\u306a\u56de\u7b54\u306f\u5f8c\u65e5\u4f1d\u3048\u3055\u305b\u3066\u3044\u305f\u3060\u304d\u307e\u3057\u305f\u3002<\/p>\n<p>\u305d\u3046\u306a\u3093\u3067\u3059\u3088\u306d\u3001\u79c1\u3082\u611f\u899a\u3067\u6271\u3063\u3066\u3044\u3066\u300cthis\u3067\u547c\u3079\u306a\u304b\u3063\u305f\u304b\u3089\u3001\u3058\u3083\u3042\u5909\u6570\u540d\u3067\u547c\u3073\u51fa\u305d\u3046\u300d\u7a0b\u5ea6\u306e\u304a\u4ed8\u304d\u5408\u3044\u3057\u304b\u3057\u3066\u3053\u306a\u304b\u3063\u305f\u306e\u3067\u3059\u3002\u307e\u3041\u3001\u305d\u308c\u3067\u3082\u66f8\u3051\u3066\u3057\u307e\u3046\u3068\u3044\u3046\u4e8b\u306a\u3093\u3067\u3059\u3051\u3069\u3001\u3042\u304f\u307e\u3067\u30b9\u30af\u30fc\u30eb\u306e\u304a\u624b\u4f1d\u3044\u306a\u306e\u3067\u3053\u3053\u306f\u660e\u78ba\u306b\u3057\u306a\u3044\u3068NG\u3067\u3059\u3002<\/p>\n<h3>\u307e\u305a\u306f\u5927\u307e\u304b\u306a\u5185\u5bb9\u3067<\/h3>\n<p>\u57fa\u672c\u7684\u306b\u82f1\u8a9e\u306e\u3010this\u3011\u3068\u540c\u3058\u3067\u3059\u3002<\/p>\n<div class=\"borderBox\">\n<p>this = \u4eca\u9078\u629e\u3057\u3066\u3044\u308b\u3082\u306e = \u4eca\u30b9\u30b3\u30fc\u30d7\u3057\u3066\u3044\u308b\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u4e0a\u4f4d\u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/p>\n<\/div>\n<p>\u3053\u308c\u3092\u7406\u89e3\u3059\u308b\u306b\u306f\u3001\u307e\u305a\u3010\u30b9\u30b3\u30fc\u30d7\u3011\u3068\u3044\u3046\u8a00\u8449\u306e\u7406\u89e3\u304c\u5fc5\u8981\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h3>\u30af\u30ed\u30fc\u30d0\u30eb\u30b9\u30b3\u30fc\u30d7\u3068\u30ed\u30fc\u30ab\u30eb\u30b9\u30b3\u30fc\u30d7<\/h3>\n<p>\u30b9\u30b3\u30fc\u30d7\u306f\u5927\u5225\u3059\u308b\u3068\u3010\u30b0\u30ed\u30fc\u30d0\u30eb\u30b9\u30b3\u30fc\u30d7\u3011\u3068\u3010\u30ed\u30fc\u30ab\u30eb\u30b9\u30b3\u30fc\u30d7\u3011\u306e2\u7a2e\u985e\u3057\u304b\u3042\u308a\u307e\u305b\u3093\u3002<br \/>\n\u305d\u3057\u3066\u30ed\u30fc\u30ab\u30eb\u30b9\u30b3\u30fc\u30d7\u306e\u4e2d\u306b\u3010\u95a2\u6570\u30b9\u30b3\u30fc\u30d7\u3011\u3010\u30d6\u30ed\u30c3\u30af\u30b9\u30b3\u30fc\u30d7\u3011\u3068\u3044\u3046\u5206\u985e\u304c\u5b58\u5728\u3057\u307e\u3059\u3002<\/p>\n<div class=\"paperBox\">\u251c\u2500\u2500 \u30ed\u30fc\u30ab\u30eb\u30b9\u30b3\u30fc\u30d7<br \/>\n\uff5c\u3000\u3000\u3000\u3000\u251c\u2500\u2500\u95a2\u6570\u30b9\u30b3\u30fc\u30d7<br \/>\n\uff5c\u3000\u3000\u3000\u3000\u2514\u2500\u2500\u30d6\u30ed\u30c3\u30af\u30b9\u30b3\u30fc\u30d7<br \/>\n\u2514\u2500\u2500 \u30b0\u30ed\u30fc\u30d0\u30eb\u30b9\u30b3\u30fc\u30d7<\/div>\n<p>\u7d75\u306b\u66f8\u304f\u3068\u3053\u3093\u306a\u611f\u3058\u3067\u3059\u3002<\/p>\n<h4>\u30b0\u30ed\u30fc\u30d0\u30eb\u30b9\u30b3\u30fc\u30d7\u3068\u306f<\/h4>\n<p>\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u3069\u3053\u304b\u3089\u3067\u3082\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u5909\u6570\u306e\u4e8b\u3067\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3001JavaScript\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u305f\u969b\u306bFunction\u306e\u4e2d\u3067\u5ba3\u8a00\u3057\u305f\u5909\u6570\u3092function\u306e\u5916\u3067\u547c\u3073\u51fa\u305d\u3046\u3068\u3057\u305f\u6642\u306b\u306f\u30a8\u30e9\u30fc\u304c\u6d3e\u751f\u3057\u307e\u3059\u304c\u3001function\u306e\u5916\u3067\u5ba3\u8a00\u3057\u305f\u5909\u6570\u3092function\u5185\u3067\u5229\u7528\u3059\u308b\u5834\u5408\u306f\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u305b\u3093\u3002(\u72b6\u6cc1\u306b\u3082\u3088\u308a\u307e\u3059\u304c)<\/p>\n<pre>var scope = 'global_scope';\r\n\r\n\/\/ \u30c8\u30c3\u30d7\u30ec\u30d9\u30eb\u304b\u3089\u306e\u30a2\u30af\u30bb\u30b9\r\nconsole.log(scope); \r\n\r\n\/\/ \u95a2\u6570\u5185\u304b\u3089\u306e\u30a2\u30af\u30bb\u30b9\r\n(function () {\r\n  console.log(scope);\r\n})();<\/pre>\n<p>\u4e0a\u306e\u5834\u5408\u30014\u884c\u76ee\u30018\u884c\u76ee\u3068\u3082\u306b\u3010global_scope\u3011\u3068\u3044\u3046\u6587\u5b57\u3092\u30b3\u30f3\u30bd\u30fc\u30eb\u306b\u66f8\u304d\u3060\u3057\u307e\u3059\u3002<br \/>\n\u3061\u306a\u307f\u306b\u3001\u3053\u308c\u306f\u3053\u306e\u3088\u3046\u306b\u66f8\u3044\u3066\u3082\u540c\u3058\u3067\u3059\u3002\uff08\u3053\u3053\u3089\u8fba\u306ffunction\u306e\u6271\u3044\u65b9\u3067\u3059\u306d\uff09<\/p>\n<pre>var scope = 'global_scope';\r\n\r\n\/\/ \u30c8\u30c3\u30d7\u30ec\u30d9\u30eb\u304b\u3089\u306e\u30a2\u30af\u30bb\u30b9\r\nconsole.log(scope);\r\n\r\n\/\/ \u95a2\u6570\u5185\u304b\u3089\u306e\u30a2\u30af\u30bb\u30b9\r\ntest();\r\nfunction test() {\r\n  console.log(scope);\r\n}<\/pre>\n<h4>\u30ed\u30fc\u30ab\u30eb\u30b9\u30b3\u30fc\u30d7\u3068\u306f<\/h4>\n<p>\u5148\u7a0b\u306eScript\u3092\u30ed\u30fc\u30ab\u30eb\u30b9\u30b3\u30fc\u30d7\uff08function\u306e\u4e2d\u3067\u306e\u5ba3\u8a00\uff09\u306b\u3057\u3066\u307f\u307e\u3059\u3002\u203b\u6587\u5b57\u3060\u3051\u5909\u3048\u307e\u3057\u305f\u3002<\/p>\n<pre>function test() {\r\n  var scope = 'local_scope';\r\n  console.log(scope);\r\n}\r\n\/\/ \u30c8\u30c3\u30d7\u30ec\u30d9\u30eb\u304b\u3089\u306e\u30a2\u30af\u30bb\u30b9\r\nconsole.log(scope);\r\n\r\n# \u7d50\u679c =&gt; 'scope' is not defined<\/pre>\n<p>\u3010'scope' is not defined\u3011= \u300cscope\u3068\u3044\u3046\u5909\u6570\u3092\u898b\u3064\u3051\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u305b\u3093\u300d\u3068\u3044\u3046\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3059\u3002<br \/>\n\u3053\u308c\u306f\u4e0a\u4f4d\u306e\u5909\u6570\u306f\u4e0b\u4f4d\u3067\u8aad\u3081\u308b\u3051\u3069\u3001\u4e0b\u4f4d\u306e\u5909\u6570\u306f\u4e0a\u4f4d\u3067\u8aad\u3081\u306a\u3044\u3068\u3044\u3046\u4e8b\u3092\u610f\u5473\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n\u3068\u3044\u3046\u4e8b\u3067\u300e\u305d\u306e\u5834\u56fa\u6709\u306e\u5909\u6570\u5ba3\u8a00 = \u30ed\u30fc\u30ab\u30eb\u30b9\u30b3\u30fc\u30d7\u300f\u3068\u547c\u3070\u308c\u307e\u3059\u3002<\/p>\n<h4>\u30ed\u30fc\u30ab\u30eb\u30b9\u30b3\u30fc\u30d7\u306e\u95a2\u6570\u30b9\u30b3\u30fc\u30d7\u3068\u306f<\/h4>\n<p>function\u306e\u4e2d\u3067\u5229\u7528\u3055\u308c\u3066\u3044\u308b\u5909\u6570\u5ba3\u8a00\u306e\u4e8b\u3092\u6307\u3057\u307e\u3059\u3002<br \/>\n\u7406\u89e3\u304c\u96e3\u3057\u304f\u306a\u308b\u306e\u306f\u591a\u5206\u3053\u308c\u3002\u7406\u7531\u306f\u3053\u3093\u306a\u306e\u304c\u51fa\u3066\u304f\u308b\u304b\u3089\u3067\u3059\u3002<\/p>\n<pre>function test() {\r\n  var scope = 'local_scope';\r\n  function test2() {\r\n    console.log(scope);\r\n  }\r\n  test2();\r\n}\r\ntest();\r\n\r\n# \u7d50\u679c =&gt; 'local_scope'<\/pre>\n<p>\u3053\u308c\u304c\u60a9\u307f\u306e\u30dd\u30a4\u30f3\u30c8\u306b\u306a\u3063\u3066\u3057\u307e\u3046\u306e\u306f2\u3064\u306e\u7406\u7531\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<div class=\"borderBox\">\n<ol>\n<li>function\u306e\u4e2d\u306b\u8a18\u8f09\u3057\u305f\u5909\u6570\u306e\u5024\u3092function\u306e\u4e2d\u3067\u53d6\u308a\u51fa\u305b\u3066\u308b\u3058\u3083\u3093\uff01<\/li>\n<li>function \u306e\u4e2d\u3067\u5ba3\u8a00\u3057\u305f\u5909\u6570\u3092\u9055\u3046function\u306e\u4e2d\u3067\u4f7f\u3063\u3066\u308b\u3058\u3083\u3093\uff01<\/li>\n<\/ol>\n<\/div>\n<p>\u5f8c\u8ff0\u3057\u307e\u3059\u304c\u3001\u3053\u3053\u3089\u8fba\u306e\u601d\u8003\u306e\u7d44\u307f\u7acb\u3066\u304c this \u306b\u7d61\u3093\u3067\u304d\u307e\u3059\u3002<\/p>\n<h4>\u30ed\u30fc\u30ab\u30eb\u30b9\u30b3\u30fc\u30d7\u306e\u30d6\u30ed\u30c3\u30af\u30b9\u30b3\u30fc\u30d7\u3068\u306f<\/h4>\n<p>\u5b9a\u7fa9\u3068\u3057\u3066\u306f\uff5b \uff5d\u3067\u56f2\u308f\u308c\u305f\u4e2d\u3060\u3051\u3067\u6709\u52b9\u3068\u306a\u308b\u5909\u6570\u5ba3\u8a00\u306e\u4e8b\u3067\u3059\u3002<\/p>\n<p>function\u3082{ } \u3067\u56f2\u3044\u307e\u3059\u304b\u3089\u540c\u3058\u3088\u3046\u306a\u6c17\u304c\u3057\u307e\u3059\u304c\u3001{ } \u3067\u56f2\u3046\u30b7\u30fc\u30f3\u306ffunction\u3060\u3051\u3067\u306f\u7121\u3044\u305f\u3081\u30d6\u30ed\u30c3\u30af\u30b9\u30b3\u30fc\u30d7\u3068\u547c\u3070\u308c\u307e\u3059\u3002\u5177\u4f53\u7684\u306b\u306f\u4e0b\u306e\u3088\u3046\u306aif\u6587\u304c\u826f\u3044\u4f8b\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n<pre>let test = 1;\r\nif ( test == 1){\r\n    let val = '\u30d6\u30ed\u30c3\u30af\u30b9\u30b3\u30fc\u30d7\u3067\u3059'\r\n}else{\r\n    let val = '\u3053\u308c\u3082\u30d6\u30ed\u30c3\u30af\u30b9\u30b3\u30fc\u30d7\u3067\u3059'\r\n}<\/pre>\n<h3>\u4eca\u30b9\u30b3\u30fc\u30d7\u3057\u3066\u3044\u308b\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u4e0a\u4f4d\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3063\u3066\u3069\u3046\u3044\u3046\u3053\u3068\uff1f<\/h3>\n<p>\u8a71\u3092this\u306b\u623b\u3057\u307e\u3059\u3002\u3053\u3093\u306a\u30b3\u30fc\u30c9\u3092\u66f8\u3044\u3066\u307f\u307e\u3059\u3002<\/p>\n<pre class=\"\">function test(){\r\n  console.log(this);\r\n}\r\ntest();\r\n\r\n# \u7d50\u679c =&gt;  Window\u00a0{0: Window, window: Window, self: Window, document: document, name: \"\", location: Location,\u00a0\u2026}<\/pre>\n<p>\u3067\u306f\u3001\u4e0a\u3092\u3053\u3093\u306a\u611f\u3058\u306b\u5909\u3048\u3066\u307f\u307e\u3059\u3002\u4e0a\u306eScript\u3068\u306ftest\u95a2\u6570\u306e\u547c\u3073\u51fa\u3057\u65b9\u304c\u5909\u308f\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"\">function test() {\r\n    console.log(this);\r\n}\r\nvar obj = {};\r\nobj.test = test;\r\n\r\nobj.test();\r\n\r\n# \u7d50\u679c =&gt; {test: \u0192}<\/pre>\n<p>obj\u3068\u3044\u3046\u7a7a\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3057\u3066\u3001\u305d\u3053\u306btest\u3068\u3044\u3046\u5024\u3092\u767b\u9332\u3057test\u95a2\u6570\u3092\u30bb\u30c3\u30c8\u3057\u307e\u3057\u305f\u3002<br \/>\n\u3067\u3001object.test()\u3067\u30c6\u30b9\u30c8\u95a2\u6570\u3092\u547c\u3073\u51fa\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u5229\u7528\u3057\u3066\u3044\u308bfunction\u306e\u30b3\u30fc\u30c9\u306f\u5909\u308f\u3089\u306a\u3044\u306e\u306b\u7b54\u3048\u304c\u304c\u5909\u308f\u308a\u307e\u3057\u305f\u3002<br \/>\n\u7406\u7531\u306f\u3001\u6700\u521d\u6307\u793a\u3057\u3066\u3044\u305fthis\u306f\u30b0\u30ed\u30fc\u30d0\u30eb\u306athis\u3067\u3001\u6b21\u306ethis\u306f\u30d6\u30ed\u30c3\u30af\u30b9\u30b3\u30fc\u30d7\u5185\u306ethis\u3068\u306a\u3063\u3066\u3044\u308b\u304b\u3089\u3067\u3059\u3002<\/p>\n<p>\u3053\u306e\u6642 this \u304c\u793a\u3057\u3066\u3044\u308b\u306e\u306fobj\u3068\u3044\u3046\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3067\u3059\u3002\u305d\u308c\u3092\u8a3c\u660e\u3059\u308b\u305f\u3081\u306b\u4e0b\u306e\u69d8\u306b\u8a18\u8f09\u3057\u3066\u307f\u307e\u3059\u3002function\u306e\u4e2d\u3067\u547c\u3073\u51fa\u3059\u5024\u3092this.cast\u3068\u3057\u3066\u3001obj\u306b\u65b0\u3057\u3044\u5024cast\u3092\u8ffd\u52a0\u3057\u307e\u3057\u305f\u3002<\/p>\n<pre class=\"\">function test() {\r\n    console.log(this.cast);\r\n}\r\nvar obj = {};\r\nobj.test = test;\r\nobj.cast = '123';\r\nobj.test()\r\n\r\n# \u7d50\u679c =&gt; 123<\/pre>\n<p>function\u5185\u3067\u306f\u3010this.cast\u3011\u3068\u3057\u3066\u547c\u3073\u51fa\u3057\u3001\u3053\u306e\u7d50\u679c\u306fobj.cast\u306b\u767b\u9332\u3057\u305f\u5024\u300e123\u300f\u304c\u30b3\u30fc\u30eb\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u3064\u307e\u308a\u3053\u306e\u5834\u5408\u3010this.cast = obj.cast\u3011\u3068\u3044\u3046\u4e8b\u3067\u3059\u304b\u3089\u3010this = obj\u3011\u3068\u3044\u3046\u4e8b\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h4>\u3061\u3087\u3063\u3068\u8131\u7dda\u89e3\u8aac<\/h4>\n<p>\u3061\u306a\u307f\u306b\u3001{test: \u0192}\u3092\u8fd4\u3057\u3066\u3044\u308b\u30b3\u30fc\u30c9\u306e\u66f8\u304d\u65b9\u3092\u3053\u3093\u306a\u98a8\u306b\u5909\u3048\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u203b\u540c\u3058\u610f\u5473\u3067\u3059\u3002<br \/>\n\u7a7a\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u4f5c\u6210\u3057\u3066\u4e91\u3005\u3068\u3044\u3046\u52d5\u4f5c\u3092\u305b\u305a\u306b\u6700\u521d\u304b\u3089test\u3092\u767b\u9332\u3057\u305f\u72b6\u614b\u3067obj\u3092\u4f5c\u6210\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre>function test() {\r\n    console.log(this);\r\n}\r\nvar obj = {test:test};\r\nobj.test()\r\n\r\n# \u7d50\u679c =&gt; {test: \u0192}<\/pre>\n<h3>\u30b9\u30b3\u30fc\u30d7\u3068this\u306e\u95a2\u4fc2\u306b\u3064\u3044\u3066<\/h3>\n<p>\u3082\u3046\u5c11\u3057\u7815\u3044\u3066\u307f\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">function test(){\r\n  console.log(this);\r\n}\r\n\r\ntest();<\/pre>\n<p>\u3053\u306e\u4f8b\u306e\u5834\u5408\u306f\u3001test()\u306e\u30b3\u30fc\u30eb\u306f\u30b0\u30ed\u30fc\u30d0\u30eb\u30b9\u30b3\u30fc\u30d7\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<br \/>\n\u305d\u306e\u305f\u3081\u3001this\u306f\u30b0\u30ed\u30fc\u30d0\u30eb\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u6307\u3059\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true \">function test() {\r\n  console.log(this);\r\n}\r\nvar obj = {};\r\nobj.test = test;\r\n\r\nobj.test();<\/pre>\n<p>\u4e00\u65b9\u3067\u3001\u3053\u3061\u3089\u306e\u4f8b\u3067\u306f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8obj\u306e\u30d6\u30ed\u30c3\u30af\u30b9\u30b3\u30fc\u30d7\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002\u30b9\u30b3\u30fc\u30d7\u3055\u308c\u3066\u3044\u308b\u5024\u306ftest\u3067\u3059\u304b\u3089\u3053\u306e\u4e0a\u4f4d\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3067\u3042\u308b\u3010obj\u3011\u304c\u3010this\u3011\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<div class=\"pointBox\">\n<p>this \uff1d .\uff08\u30c9\u30c3\u30c8\uff09\u306e\u524d\u306e\u5024\uff08\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\uff09<\/p>\n<\/div>\n<p>\u3053\u3046\u899a\u3048\u308b\u3068\u3068\u3066\u3082\u7406\u89e3\u3057\u3084\u3059\u3044\u3067\u3059\u3002<\/p>\n<h3>\u307e\u3068\u3081<\/h3>\n<p>this\u306f\u6587\u5b57\u306b\u8d77\u3053\u305d\u3046\u3068\u3059\u308b\u3068\u7d50\u69cb\u96e3\u3057\u3044\u3067\u3059\u306d\u3002<br \/>\n\u3044\u308d\u3093\u306a\u60c5\u5831\u306b\u5f53\u305f\u308a\u691c\u8a3c\u3057\u3066\u307f\u308b\u3068\u7406\u89e3\u304c\u6df1\u307e\u3063\u3066\u3044\u304f\u3068\u601d\u3044\u307e\u3059\u306e\u3067\u3001\u305f\u304f\u3055\u3093\u306e\u60c5\u5831\u306b\u5f53\u305f\u3063\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u305d\u306e\u4ed6JavaScript\u306b\u3064\u3044\u3066\u53d7\u3051\u305f\u8cea\u554f\u306b\u3064\u3044\u3066\u306f\u500b\u3005\u307e\u3068\u3081\u3066\u884c\u304d\u307e\u3059\u3002<\/p>\n<div class=\"borderBox\">\n<ol>\n<li><a href=\"https:\/\/qol-kk.com\/wp2\/blog\/2021\/04\/04\/post-2794\/\">let \u3068 const \u3068 var \u306f\u4f55\u304c\u9055\u3046\u306e\uff1f<\/a><\/li>\n<li><a href=\"https:\/\/qol-kk.com\/wp2\/blog\/2021\/04\/05\/post-2797\/\">function\u3063\u3066\u4f55\uff1f\u3042\u308b\u6642\u3068\u306a\u3044\u6642\u3067\u4f55\u304c\u9055\u3046\u306e\uff1f<\/a><\/li>\n<li><a href=\"https:\/\/qol-kk.com\/wp2\/blog\/2021\/04\/06\/post-2810\/\">\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306f { } \u3067\u56f2\u308f\u308c\u3066\u3044\u308b\u3068\u3044\u3046\u3051\u3069\u3001function(){ } \u306e { } \u306e\u4e2d\u3082\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306a\u306e\uff1f<\/a><\/li>\n<li>this. \u3063\u3066\u3069\u3053\u3092\u6307\u3057\u3066\u3044\u308b\u306e\uff1f&lt;=\u3010\u4eca\u56de\u306e\u5185\u5bb9\u3011<\/li>\n<li><a href=\"https:\/\/qol-kk.com\/wp2\/blog\/2021\/04\/13\/post-2834\/\">JavaScript\u3068Java\u306f\u540c\u3058\u306a\u306e\uff1f<\/a><\/li>\n<\/ol>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>JavaScript\uff1a\u304a\u624b\u4f1d\u3044\u3057\u3066\u3044\u308b\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u30b9\u30af\u30fc\u30eb\u3067\u805e\u304b\u308c\u305f\u8cea\u554f\u3010this\u3063\u3066\u3069\u3053\u306e\u4e8b\uff1f\u3011 \u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u30b9\u30af\u30fc\u30eb\u306e\u751f\u5f92\u3055\u3093\u3068\u3044\u308d\u3044\u308d\u304a\u8a71\u3057\u3066\u3044\u308b\u4e2d\u3067\u51fa\u3066\u304d\u305f\u300e\u3088\u304f\u7406\u89e3\u3067\u304d\u306a\u304b\u3063\u305f\u4e8b\u300f\u306b\u3064\u3044\u3066\u3001\u3053\u306e\u969b\u307e\u3068\u3081\u3066\u304a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2041,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"sns_share_botton_hide":"","vkExUnit_sns_title":"","_vk_print_noindex":"","sitemap_hide":"","_veu_custom_css":"","veu_display_promotion_alert":"","vkexunit_cta_each_option":"","_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[36],"tags":[365,992,53,993,247,994,981],"class_list":["post-2821","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript-memorandum","tag-javascript","tag-this","tag-53","tag-993","tag-247","tag-994","tag-981"],"veu_head_title_object":{"title":"","add_site_title":""},"jetpack_publicize_connections":[],"jetpack-related-posts":[],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/qol-kk.com\/wp2\/wp-content\/uploads\/2020\/10\/nino-eye1.jpg","_links":{"self":[{"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/posts\/2821","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/comments?post=2821"}],"version-history":[{"count":0,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/posts\/2821\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/media\/2041"}],"wp:attachment":[{"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/media?parent=2821"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/categories?post=2821"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/tags?post=2821"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}