{"id":428,"date":"2004-01-24T23:00:00","date_gmt":"2004-01-24T14:00:00","guid":{"rendered":"\/?p=428"},"modified":"2004-01-24T23:00:00","modified_gmt":"2004-01-24T14:00:00","slug":"user-object-definition-in-javascript","status":"publish","type":"post","link":"https:\/\/www.hiro345.net\/blogs\/hiro345\/archives\/428.html","title":{"rendered":"User Object definition in JavaScript"},"content":{"rendered":"<p>\n\u3042\u3044\u304b\u308f\u3089\u305aJavaScript\u306b\u3064\u3044\u3066\u8272\u3005\u8abf\u3079\u3066\u307e\u3059\u3002JavaScript\u3067\u30e6\u30fc\u30b6\u30fc\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u5b9a\u7fa9\u3059\u308b\u306b\u306f\u3001\u3064\u304e\u306e\u3088\u3046\u306a\u611f\u3058\u306b\u306a\u308a\u307e\u3059\u3002\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u7528\u306e\u95a2\u6570\u3092\u5b9a\u7fa9\u3057\u3066\u3001\u5b9a\u7fa9\u3057\u305f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306eprototype\u306b\u5c5e\u6027\u3092\u8ffd\u52a0\u3057\u3066\u3044\u304d\u307e\u3059\u3002\u64cd\u4f5c\u306e\u8ffd\u52a0\u3082\u3067\u304d\u307e\u3059\u3002\u64cd\u4f5c\u306f\u5b9f\u4f53\u3092\u5225\u306b\u7528\u610f\u3057\u3066\u304a\u3044\u3066\u540d\u524d\u3067\u675f\u7e1b\u3059\u308b\u3068\u3044\u3046\u611f\u3058\u3067\u3059\u3002\u305f\u3060\u3057\u3001\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u5358\u4f4d\u3067\u306e\u540d\u524d\u7a7a\u9593\u306f\u5b9a\u7fa9\u3055\u308c\u306a\u3044\u306e\u3067\u3001\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u7528\u306e\u5c5e\u6027\u3084\u64cd\u4f5c\u306e\u5b9f\u4f53\u7528\u306b _ \u3067\u59cb\u307e\u308b\u540d\u524d\u306f\u4e88\u7d04\u3057\u3066\u304a\u3044\u3066\u3001\u901a\u5e38\u306e\u95a2\u6570\u3067\u306f _ \u3092\u4f7f\u308f\u306a\u3044\u3068\u3044\u3046\u3053\u3068\u3092\u8003\u3048\u305f\u308a\u3057\u306a\u3044\u3068\u3044\u3051\u307e\u305b\u3093\u3002\n<\/p>\n<p><div class=\"code\">\/\/ \u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf<br \/>\nfunction Target() {<br \/>\n}<br \/>\nTarget.prototype.name = &#8220;Target&#8221;<br \/>\nTarget.prototype.equals = _target_equals;<br \/>\nTarget.prototype.toString = _target_toString;<\/p>\n<p>\/\/ \u3053\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3068\u4ed6\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u7b49\u3057\u3044\u304b\u3069\u3046\u304b\u3092\u793a\u3057\u307e\u3059\u3002<br \/>\nfunction _target_equals(obj) {<br \/>\n  return obj.toString()==this.name;<br \/>\n}<br \/>\n\/\/ \u6587\u5b57\u5217\u8868\u73fe\u3092\u8fd4\u3057\u307e\u3059\u3002<br \/>\nfunction _target_toString() {<br \/>\n  return this.name;<br \/>\n}<\/p><\/div>\n<\/p>\n<p>\n\u300c\u5b9f\u88c5\u306e\u7d99\u627f\u300d\u3089\u3057\u304d\u3053\u3068\u3092\u5b9f\u73fe\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u308b\u3088\u3046\u3067\u3059\u304c\u3001JavaScript\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u95a2\u3057\u3066\u306f\u578b\u306b\u3088\u308b\u30c1\u30a7\u30c3\u30af\u306f\u3067\u304d\u306a\u3044\u306e\u3067\u500b\u4eba\u7684\u306b\u306f\u3042\u307e\u308a\u610f\u5473\u304c\u306a\u3044\u304b\u306a\u3068\u3044\u3046\u611f\u3058\u3067\u3059\u3002\u305b\u3063\u304b\u304f\u64cd\u4f5c\u306e\u5b9f\u4f53\u3092\u6307\u5b9a\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308b\u306e\u3067\u3001\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u30b3\u30f3\u30dd\u30b8\u30b7\u30e7\u30f3\u306e\u8003\u3048\u65b9\u3067\u62e1\u5f35\u3057\u3066\u3044\u304f\u65b9\u304c\u3001\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u5f79\u5272\u3082\u308f\u304b\u308a\u3084\u3059\u304f\u306a\u308a\u307e\u3059\u304b\u3089\u826f\u3044\u3068\u601d\u3044\u307e\u3059\u3002\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u304c\u5c11\u3005\u9577\u304f\u306a\u308a\u307e\u3059\u3051\u3069\u3001\u7d99\u627f\u306e\u7f60\u306b\u306f\u307e\u308a\u306b\u304f\u304f\u306a\u308b\u306e\u3067\u3001\u4fdd\u5b88\u6027\u306f\u9ad8\u307e\u308b\u3068\u601d\u3044\u307e\u3059\u3002\n<\/p>\n<p><!--more--><\/p>\n<p>\nJavaScript\u306b\u306fObject\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u3042\u308b\u306e\u3067\u3001\u305d\u308c\u3092\u7d99\u627f\u3059\u308b\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u3066\u304a\u304d\u307e\u3059\u3002\uff08Object\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306f\u6697\u9ed9\u306b\u7d99\u627f\u3055\u308c\u3066\u3044\u308b\u3088\u3046\u306a\u306e\u3067\u3001\u660e\u793a\u7684\u306b\u6307\u5b9a\u3059\u308b\u5fc5\u8981\u306f\u306a\u3044\u3089\u3057\u3044\u306e\u3067\u3059\u304c\u3001\u4f8b\u306e\u7d39\u4ecb\u3068\u3044\u3046\u3053\u3068\u3067\u793a\u3057\u3066\u304a\u304d\u307e\u3059\u3002\uff09\n<\/p>\n<p><div class=\"code\">\/\/ \u3053\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3068\u4ed6\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u7b49\u3057\u3044\u304b\u3069\u3046\u304b\u3092\u793a\u3057\u307e\u3059\u3002<br \/>\nfunction _extendedobject_equals(obj) {<br \/>\n  return obj.toString()==this.name;<br \/>\n}<br \/>\n\/\/ \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u6587\u5b57\u5217\u8868\u73fe\u3092\u8fd4\u3057\u307e\u3059\u3002<br \/>\nfunction _extendedobject_toString() {<br \/>\n  return this.name;<br \/>\n}<\/p>\n<p>\/\/ \u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf<br \/>\nfunction ExtendedObject() {<br \/>\n  \/\/ \u30d7\u30ed\u30d1\u30c6\u30a3\u306e\u521d\u671f\u5316<br \/>\n  this.base = Object;<br \/>\n  this.base();<br \/>\n  this.name = &#8220;ExtendedObject&#8221;<\/p>\n<p>  \/\/ \u30e1\u30bd\u30c3\u30c9\u306e\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0<br \/>\n  this.equals = _extendedobject_equals;<br \/>\n  this.toString = _extendedobject_toString;<br \/>\n}<br \/>\nExtendedObject.prototype = new Object;<\/p>\n<p>function _subobject_setPoint(point) {<br \/>\n  this.point = point;<br \/>\n}<br \/>\nfunction _subobject_getPoint() {<br \/>\n  return this.point;<br \/>\n}<br \/>\nfunction SubObject() {<br \/>\n  this.base = ExtendedObject;<br \/>\n  this.base();<br \/>\n  this.point = 100;<br \/>\n  this.setPoint = _subobject_setPoint;<br \/>\n  this.getPoint = _subobject_getPoint;<br \/>\n}<br \/>\nSubObject.prototype = new ExtendedObject;\n<\/p><\/div>\n<\/p>\n<p>\n\u3053\u3053\u3067\u306f\u3001Object &lt;- ExtendedObject &lt;- SubObject \u3068\u3044\u3046\u95a2\u4fc2\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u5b9a\u7fa9\u3092\u3057\u3066\u3044\u307e\u3059(&lt;-\u306f\u7d99\u627f\u306e\u610f\u5473)\u3002JavaScript\u306e\u5834\u5408\u306f\u52d5\u7684\u306b\u5c5e\u6027\u3084\u64cd\u4f5c\u3092\u8ffd\u52a0\u3067\u304d\u3066\u3057\u307e\u3046\u306e\u3067\u3001\u3061\u3087\u3063\u3068\u6163\u308c\u306a\u3044\u3068\u308f\u304b\u308a\u306b\u304f\u3044\u611f\u3058\u304c\u3057\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3042\u3044\u304b\u308f\u3089\u305aJavaScript\u306b\u3064\u3044\u3066\u8272\u3005\u8abf\u3079\u3066\u307e\u3059\u3002JavaScript\u3067\u30e6\u30fc\u30b6\u30fc\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u5b9a\u7fa9\u3059\u308b\u306b\u306f\u3001\u3064\u304e\u306e\u3088\u3046\u306a\u611f\u3058\u306b\u306a\u308a\u307e\u3059\u3002\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u7528\u306e\u95a2\u6570\u3092\u5b9a\u7fa9\u3057\u3066\u3001\u5b9a\u7fa9\u3057\u305f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306eprototype\u306b\u5c5e &hellip; <a href=\"https:\/\/www.hiro345.net\/blogs\/hiro345\/archives\/428.html\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-428","post","type-post","status-publish","format-standard","hentry","category-etc"],"_links":{"self":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/posts\/428","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/comments?post=428"}],"version-history":[{"count":0,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/posts\/428\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/media?parent=428"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/categories?post=428"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/tags?post=428"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}