{"id":444,"date":"2022-08-30T15:01:27","date_gmt":"2022-08-30T15:01:27","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/09\/how-to-create-a-js-prototype-class-in-external-file-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:01:27","modified_gmt":"2022-08-30T15:01:27","slug":"how-to-create-a-js-prototype-class-in-external-file-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/how-to-create-a-js-prototype-class-in-external-file-collection-of-common-programming-errors\/","title":{"rendered":"how to create a js prototype class in external file-Collection of common programming errors"},"content":{"rendered":"<p>To set <code>log<\/code> on the <code>Logger<\/code> instance to an empty array, use <code>this.log = []<\/code>, not <code>var log<\/code>. The latter creates a private variable, which you can&#8217;t access outside the function.<\/p>\n<p>Also, <code>Logger.log<\/code> means: access the <code>log<\/code> property on the <code>Logger<\/code> function. Here you want the instance instead, so use <code>this.log<\/code> (like you did in <code>ReadLog<\/code>).<\/p>\n<p id=\"rop\"><small>Originally posted 2013-11-09 19:43:02. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>To set log on the Logger instance to an empty array, use this.log = [], not var log. The latter creates a private variable, which you can&#8217;t access outside the function. Also, Logger.log means: access the log property on the Logger function. Here you want the instance instead, so use this.log (like you did in [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-444","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/444","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=444"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/444\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=444"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=444"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=444"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}