I am Hack Sparrow
Captain of the Internets.

Understanding directory references in Node.js

So, there are three different ways to refer to directories in Node.js; namely - dot notation (./ and ../), __dirname, and process.cwd(). While all of them might seem to refer to the same thing, they can become a source of confusion and bugs, if they are not understood well. Let's examine how they work. Create a directory named base with the following tree under it: [code] . ├── app.js └── /one ├── on ...

JSLint from the Command Line

Maybe you have heard about JSLint, or maybe not. If you haven't yet, it is a popular JavaScript tool authored by Douglas Crockford, which helps you optimize your JavaScript code by telling you the problem areas and suggesting solutions for the same. Quite a nifty tool, try it here. Despite it's usefulness, the JSLint as we know it, has a little problem: it is an online tool, hosted on Crockford's server. Wouldn't it be wonderful if JSLint were a command ...

Loading JavaScript Modules in the Browser with Component.js

Is there a way to enable the module loading capability of Node.js in the browser? How wonderful it would be if you could write JavaScript modules the Node.js way and load them in the browser. There have been many attempts at doing this. Notable among them are RequireJS and Browserify. Both got things done one or the other way, but are unnecessarily complicated and a pain to use. If you type "browserify" or "requirejs" ...

JavaScript Array-like Objects

Have you heard about array-like objects in JavaScript? If no, this is a good post to learn about them. Array-like objects are not a separate object type, they are the same old object we are familiar with, except they 'look' like arrays. What do I mean by that? Let's find out. You might be familiar with the arguments variable which every JavaScript function has access to by default. We access its items using arguments[0], arguments[1] etc. Let's take a lo ...

JavaScript Test – Round One

Applying for a job somewhere as a JavaScript developer? Or just wanna see how much of JavaScript you know? Here is something useful and fun for you. Let's assume I won't consider anyone for the next round, who fails to answer atleast 95% of these questions. Yes, this is the first round :twisted: 1. What are some negative stuff about JavaScript, the language? 2. What can you do to mitigate the effects of those negative stuff? 3. What are the primitive data types in JavaScript? 4. What ar ...