“It hurts when I do this!” “…Don’t do that?”
I admit it: I’m a beginner when it comes to JavaScript and web development, trying to navigate that rocky climb to intermediate skill level and whatever perilous terrain lies beyond. So I know I’m going to make mistakes — it’s part of learning!
That said, the biggest and most frustrating brick walls I’ve encountered have come not from syntax errors or JavaScript quirks or inability to visualize problem solutions, but from the simple act of trying to jam a square peg into a round hole.
Some things I’ve learned in the past couple of weeks:
- Don’t try to return something from an asynchronous function, unless it’s a Promise.
- Don’t try to forward information directly from one page to another. There are some ways to retain information, but not this way.
- Don’t try to make a POST request from an external API redirect somebody’s browser. Why would you even do that?
- Trying to make an infinitely nesting data structure and an infinitely extending URL is a Bad and Dumb Plan.
Go ahead — you can laugh! Once I pulled myself out of coding tunnel vision even I laughed at myself for some of these. But hey, each and every one was a learning experience. I understand how to properly use asynchronous functions much better after beating my head against their most obvious pitfalls. I have a deeper understanding of HTTP’s statelessness after trying to force it to have state.
And for the last two, well — I’ve learned that sometimes you have to take a step back and ask, “Is what I’m doing crazy?” And if the answer is “yes,” maybe just… stop. Stop for a minute and refresh yourself on what you’re actually trying to accomplish. Chances are there is another, saner path to your goal.
And if all the StackOverflow answers you find when you google your issue express wariness and incredulity, maybe don’t spend the next hour trying to make it work anyway.
