title: When working with NodeJS FS mkdir, what is the importance of including callbacks?
body: <p>I'm playing with the <code>NodeJS REPL</code> console and following this tutorial.</p>
  
  <p><a href="http://www.tutorialspoint.com/nodejs/nodejs_file_system.htm" rel="noreferrer">http://www.tutorialspoint.com/nodejs/nodejs_file_system.htm</a></p>
  
  <p>I'm focusing on the <code>File System(FS)</code> module. Let's look at the <code>mkdir</code> function used for creating directories.</p>
  
  <p>According to TutorialsPoint, this  is how you create a directory with FS</p>
  
  <pre><code>var fs = require("fs");
  
  console.log("Going to create directory /tmp/test");
  fs.mkdir('/tmp/test',function(err){
     if (err) {
         return console.error(err);
     }
     console.log("Directory created successfully!");
  });
  </code></pre>
  
  <p>They specifically say you need this syntax</p>
  
  <pre><code>fs.mkdir(path[, mode], callback)
  </code></pre>
  
  <p>Well I just tried using less code without the callback and it worked.</p>
  
  <pre><code>var fs = require('fs');
  fs.mkdir('new-directory');
  </code></pre>
  
  <p>And the directory was created. The syntax should just be</p>
  
  <pre><code>fs.mkdir(path);
  </code></pre>
  
  <p>I have to ask, what is the purpose of the callback and do you really need it? For removing a directory I could understand why you would need it, in case the directory didn't exist. But I can't see what could possibly go wrong with the <code>mkdir</code> command. Seems like a lot of unnecessary code.</p>