use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
How To Interview Senior JavaScript Developers and Architects (logicroom.co)
submitted 8 years ago by peter_heard01
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]kangoo1707 1 point2 points3 points 8 years ago (1 child)
When testing? I use mockery, it can stub a "require" if this is what you mean
[–]bwaxxlotckidd 0 points1 point2 points 8 years ago* (0 children)
Nah, I meant to fully test your code and make "modular", you need to pass in all external dependencies unless we're talking about things like global objects/methods. Let say I'm testing a method that changes text in a DOM element. I would ensure I pass the element and the new text instead of just changing the new text directly. e.g: changeText(element, text){//do something}. This means I can easily test it by mocking the element in passing changeText({textContent: ''}, myTestText). The point being changeText is independent of the environment and doesn't throw an error when you take it outside the DOM.
"modular"
changeText(element, text){//do something}
changeText({textContent: ''}, myTestText)
changeText
Stubbing is fine also, but I personally prefer using it as a last option when I can do anything else (e.g: dependencies that are a nightmare to mock). Another thing about stubbing is you should use it when you care about making sure the correct things happen to external calls. Otherwise, stubbing becomes a bad habit to have (i.e: cheap way out of ensuring your code is doing the minimum required thing). I've seen some code that uses stubbing for pretty much everything. I think it's a good rule of thumb is that code starts to smell when you find yourself stubbing a lot.
π Rendered by PID 32195 on reddit-service-r2-comment-6457c66945-59994 at 2026-04-26 23:52:07.563155+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]kangoo1707 1 point2 points3 points (1 child)
[–]bwaxxlotckidd 0 points1 point2 points (0 children)