Skip to main content

Search and study the issue

An actual observation we have about some questions is the fact that doing a web search using the title of the question yields the answer right there in the search results if you click through. Many times, the answer is already available on Stack Overflow. That might sound silly to you, but it’s real. If you post a question that is similar enough to another question that was previously posted, it will likely get closed as a duplicate of the other question. If that happens to your question, you should read the answers of the other question to learn more.

If your question is significantly different from the top search results, be sure to explain that in your question. It’s a very good idea to share links to the questions that you already encountered, and explain why the answers didn’t help or weren’t applicable to your problem. If you don't do this, chances are still very good that your question will be closed as a duplicate. The more you share about what you researched and what you tried that didn’t work, the more likely you will get the specific help you need.

Constructing a helpful web search is not very difficult. Here are a few tips:

Search using names of technologies

Be sure to add the names of relevant languages, runtimes, frameworks, objects, methods, and keywords.

One very common problem in JavaScript and Dart is observing that the use of async/await in a forEach lambda function doesn’t work the way you’d expect. Here is an example in JavaScript:

const list = [ ... ];
list.forEach(async item => {
console.log(`Item ${item}`)
await doSomethingAsync(item);

When run, this code iterates each element of the array without stopping to wait for the asynchronous work to complete for each one. The console output looks like this:

Item a
Item b
Item c

The confusion lies in seeing "After" logged right after "Before", with the items happening later. One might initially expect the "After" to be logged after each item is is iterated.

A solution to this can be found by performing a search with “javascript foreach async await”. Google returns the following as the very first result, which goes straight to Stack Overflow and offers many answers with many possible solutions:

Using async/await with a forEach loop - javascript

You can see that this is a highly upvoted question - that’s an indicator of how common the problem is. Yet, questions on this topic keep getting posted. In fact, Google shows other questions from Stack Overflow grouped immediately below it which are essentially the same issue but worded slightly differently. There is plenty here to learn before posting a question, and you’ll probably get your answer faster if you choose to study search results first, even if the titles on the results don’t say what you’re looking for.

Search using the error message

If you are doing your best to learn how to read a stack trace, you should have identified an error message in plain English. Chances are very good that this has come up before and has already been asked in an existing question. Doing a web search using that error message is a good place to start. You might want to put quotes around the entire string to help the search engine know that it should favor exact matches. Also consider removing what appear to be variable parts of the message to keep the results focused.

For example, it’s extremely common for Java programmers to encounter an error called a “NullPointerException”. Unfortunately, it’s also common for poorly researched questions to include this error in the question without having done any research on what it means. If you do a web search, you will certainly encounter this question on Stack Overflow with a detailed description of what it means and how to diagnose it:

What is a NullPointerException, and how do I fix it?

If you encounter this error and post a question about it without explaining what you’ve done to debug it, your question will likely be closed as a duplicate of the above question as a hint about how you should continue your debugging. The same is true of other common errors in other languages.

Find and read the documentation

It’s an old insult to tell people to “RTFM” who don’t know what they’re doing with some software product. That particular response is not appropriate for Stack Overflow, but it has a point: there is a good chance the documentation contains helpful information.

Before asking a question about a specific technology or framework, you should find and study its documentation. Popular technology is typically very well documented, and the engineers put effort into making sure it addresses common issues.

If you want to search the documentation for some specific technology, but it doesn’t have a built-in search feature, Google can still help. If you add “” as a search term, the results will only include pages from that particular site. For example, if you’re looking for details about React, add “” to your query to see what the documentation has to say about your other search terms.

Record what you already found

If your searches ended up finding a bunch of information, but it wasn’t exactly what you needed, copy and paste those URLs into your question, cite any relevant text of those pages (formatted as a blockquote), and explain why it wasn’t helpful, so the reader knows what you already tried. This also shows that you put effort into the problem, and might help avoid your question getting downvoted for lack of research.