{"id":2058,"date":"2014-08-11T04:51:50","date_gmt":"2014-08-11T04:51:50","guid":{"rendered":"http:\/\/www.gisdeveloper.co.kr\/?p=2058"},"modified":"2017-01-27T10:48:00","modified_gmt":"2017-01-27T01:48:00","slug":"javascript-%eb%b3%b4%eb%8b%a4-%eb%8d%94-%ec%a0%95%ed%99%95%ed%95%9c-%ed%83%80%ec%9e%85type%ec%9d%84-%ec%96%bb%eb%8a%94-%ed%95%a8%ec%88%98","status":"publish","type":"post","link":"http:\/\/www.gisdeveloper.co.kr\/?p=2058","title":{"rendered":"[JavaScript] \ubcf4\ub2e4 \ub354 \uc815\ud655\ud55c \ud0c0\uc785(type)\uc744 \uc5bb\ub294 \ud568\uc218"},"content":{"rendered":"<p>\uc790\ubc14\uc2a4\ud06c\ub9bd\ud2b8\uc5d0\ub294 \ud574\ub2f9 \uac1d\uccb4\uac12\uc5d0 \ub300\ud55c \ud0c0\uc785\uc744 \uc5bb\ub294 \uc608\uc57d\uc5b4\ub85c typeof\ub97c \uc9c0\uc6d0\ud569\ub2c8\ub2e4. \uadf8\ub7ec\ub098 \uc694\ub188\uc774 \uadf8\ub2e4\uc9c0 \uc815\ud655\uce58 \uc54a\ub294 \ub140\uc11d\uc778\uc9c0\ub77c \uc774\ubcf4\ub2e4 \ub354 \uc815\ud655\ud55c \ud0c0\uc785\uc744 \uc5bb\uc744 \ud544\uc694\uac00 \uc788\uc744 \uc2dc\uc5d0 \ub2e4\uc74c \ud568\uc218\ub97c \uc0ac\uc6a9\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<pre>\r\nfunction getType(x) {\r\n    if (x == null) {\r\n        return 'null';\r\n    }\r\n\r\n    var t = typeof x;\r\n    if (t != \"object\") {\r\n        return t;\r\n    }\r\n\r\n    var c = Object.prototype.toString.apply(x);\r\n    c = c.substring(8, c.length - 1); \/\/ [object ?]\uc758 \ud2b9\uc131\uc744 \uc774\uc6a9\ud568\r\n\r\n    if (c != \"Object\") {\r\n        return c;\r\n    }\r\n\r\n    if (c.constructor == \"Object\") {\r\n        return c;\r\n    } else {\r\n        var s = x.constructor.toString();\r\n        var i = s.indexOf(\"(\");\r\n        return s.substring(9, i); \/\/ function ?( ... \uc758 \ud2b9\uc131\uc744 \uc774\uc6a9\ud568\r\n    }\r\n\r\n    return \"unknown type\";\r\n}\r\n<\/pre>\n<p>\uc704\uc758 \ucf54\ub4dc\uc5d0 \ub300\ud55c \ud14c\uc2a4\ud2b8\ub294 \uc544\ub798\uc640 \uac19\uc2b5\ub2c8\ub2e4.<\/p>\n<pre>\r\nfunction CTR(a) {\r\n    this.a = a;\r\n};\r\n\r\ndocument.write(typeof CTR + \" , \" + getType(CTR));\r\n\r\nvar c = new CTR(1);\r\ndocument.write(typeof c + \" , \" + getType(c));\r\n        \r\ndocument.write(typeof new Date() + \" , \" + getType(new Date()));\r\ndocument.write(typeof new Array() + \" , \" + getType(new Array()));\r\ndocument.write(typeof 1 + \" , \" + getType(1));\r\ndocument.write(typeof \"hi\" + \" , \" + getType(\"hi\"));\r\ndocument.write(typeof this.document + \" , \" + getType(this.document));\r\n<\/pre>\n<p><P>\uc2e4\ud589 \uacb0\uacfc\ub294 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4.<\/P><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gisdeveloper.co.kr\/wp-content\/uploads\/1\/1370282756.png\" class=\"aligncenter\" width=\"350\" height=\"212\" alt=\"\uc0ac\uc6a9\uc790 \uc0bd\uc785 \uc774\ubbf8\uc9c0\" \/><\/p>\n<p><P>\uc2e4\ud589\uacb0\uacfc\uc5d0 \ub300\ud55c \uac01 \ub77c\uc778\uc758 \uccab\ubc88\uc9f8\ub294 \uc790\ubc14\uc2a4\ud06c\ub9bd\ud2b8\uc5d0\uc11c \uc81c\uacf5\ud558\ub294 typeof\ub97c \uc0ac\uc6a9\ud55c \uac83\uc774\uace0 \ub450\ubc88\uc9f8\ub294 \ubcf4\ub2e4 \ub354 \uc815\ud655\ud55c \ud0c0\uc785\uc744 \uc5bb\uc744 \uc218 \uc788\ub294 getType \ud568\uc218\ub97c \uc0ac\uc6a9\ud55c \uac83\uc785\ub2c8\ub2e4.<\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\uc790\ubc14\uc2a4\ud06c\ub9bd\ud2b8\uc5d0\ub294 \ud574\ub2f9 \uac1d\uccb4\uac12\uc5d0 \ub300\ud55c \ud0c0\uc785\uc744 \uc5bb\ub294 \uc608\uc57d\uc5b4\ub85c typeof\ub97c \uc9c0\uc6d0\ud569\ub2c8\ub2e4. \uadf8\ub7ec\ub098 \uc694\ub188\uc774 \uadf8\ub2e4\uc9c0 \uc815\ud655\uce58 \uc54a\ub294 \ub140\uc11d\uc778\uc9c0\ub77c \uc774\ubcf4\ub2e4 \ub354 \uc815\ud655\ud55c \ud0c0\uc785\uc744 \uc5bb\uc744 \ud544\uc694\uac00 \uc788\uc744 \uc2dc\uc5d0 \ub2e4\uc74c \ud568\uc218\ub97c \uc0ac\uc6a9\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. function getType(x) { if (x == null) { return &#8216;null&#8217;; } var t = typeof x; if (t != &#8220;object&#8221;) { return t; } var c = &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/www.gisdeveloper.co.kr\/?p=2058\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;[JavaScript] \ubcf4\ub2e4 \ub354 \uc815\ud655\ud55c \ud0c0\uc785(type)\uc744 \uc5bb\ub294 \ud568\uc218&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[88],"tags":[],"class_list":["post-2058","post","type-post","status-publish","format-standard","hentry","category-javascript"],"_links":{"self":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/2058","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2058"}],"version-history":[{"count":1,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/2058\/revisions"}],"predecessor-version":[{"id":2846,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/2058\/revisions\/2846"}],"wp:attachment":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2058"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2058"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2058"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}