Object.keys makes the LogGenerator completely obsolete:
Object.keys
const msg = { type: 'notify', text: 'Hello World' }; Object.keys(Log)[msg.type](msg.text);
as
class Log { static notify() { ... } }
is really just syntactic sugar for
function Log() {} Log.notify = function() { ... }
Thank you for the insight! I haven't had any experience with Object.keys() before, and my use of Class syntax in JS so far is still limited.
Thank you for the suggestion.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Object.keys
makes the LogGenerator completely obsolete:as
is really just syntactic sugar for
Thank you for the insight! I haven't had any experience with Object.keys() before, and my use of Class syntax in JS so far is still limited.
Thank you for the suggestion.