re: Namespaces and Javascript: I Don’t Know What I’m Doing VIEW POST

re: What I would do is to have a file from which I export constant variables. For example: const addPost = ‘post/add’ const addComment = ‘comment/add’ ...

If you'll excuse me, I'm not really seeing what that buys me. I guess I knew that const was added to ES at the same time as let. Can you do const addPost = function () { /* adding post here */ }?

My prime concern is keeping my "toys" to the corner of the "playground" so nobody else's stuff gets mixed up in mine, and vice versa. It isn't immediately clear what this does to help me.

(Disclaimer: JS Dev is one of the hats I wear only rarely. I've looked at Vue.JS once, maybe. People tell me it's nice.)


I’m sorry, now that I look twice, my answer is pretty misleading.

But just to finish my idea:
const addPost = ‘post/add’
You could define this as an obj prop:
addPost { ...}

Anyway, it doesn’t seem to be practical. There are definitely better ways that have already been mentioned.

code of conduct - report abuse