One of the most confusing things in JavaScript, I found was namespacing. So, I learned about it and thought to share the notes with everyone who is...
For further actions, you may consider blocking this person and/or reporting abuse
You can achieve the same effect without the use of immediately invoked function expressions using ES6 modules. Or even better, if youโre using TypeScript, you can just use the
namespace
keyword (TypeScript fanatic here).Thanks for the information dude
Would love if you can share any resource for my help and I don't know much about typescript ๐ ๐ฅ
You can read generally about the module specifications here, for full browser support youโd need to use a bundler like Parcel, Webpack, Rollup, etc.
TypeScript adds a
namespace
keyword which is essentially just syntax sugar that compiles to JavaScript modules namespaced via the ES6 module system, or if you need full browser support and are compiling to ES5, itโll compile to a method similar to what youโve shown above. You can read more about TypeScript namespaces hereThanks for your time and references
Mat - Do you have to use a bundler, or just go through some sort of server? I understood the latter, but not tried it w/o a bundler so I can't say for sure. Once it gets out of the bundler, it probably won't be a module anyway.
Also, where did you get your user pic here? I've been looking to create one of my own & I like that style.
In an environment that supports ES6 natively (so, Node.js Server, Chrome, or Firefox) you donโt need a bundler, you can use ES6 modules natively.
Also, here
The TypeScript site has a really good, simple Migrating from JavaScript guide that will get you started with TypeScript. There are lots of JavaScript "improvement" languages out there, but TypeScript seems to have caught on like no other; it's the 4th most popular languge in GitHub as of last year.
wow, so much information dude
Thanks
okay that's something really helpful cheers๐ฅ๐ฅ
Thanks, happy it helped
There's a much better & simpler way to do it without using namespacing. Use const while declaring further iteration instead of var or let.
Thanks you took time to comment and have read
But I think that declaring const every time will result in many number of variables and that becomes harder for me to handle.
BTW good to know your thoughts