how to create a js prototype class in external file-Collection of common programming errors
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’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 ReadLog
).
Originally posted 2013-11-09 19:43:02.