Hi there.
I’m Molly Duggan, and I do web development work. I also read about web development a lot. You can check out what I’m currently reading at The Daily Dev.
You can contact me at molly [dot] duggan [at] gmail.
Hi there.
I’m Molly Duggan, and I do web development work. I also read about web development a lot. You can check out what I’m currently reading at The Daily Dev.
You can contact me at molly [dot] duggan [at] gmail.
A list of tons of resources. Some of these are sites I often link to; others are new to me. Nice list.
Sent to me by my cousin. Love it!
Exploring JavaScript's Logical OR Operator
Comparisons and truthiness/falsiness are notoriously a little wonky in JavaScript, and I pretty much jump at any opportunity to learn a little more about them.
In other news, Merry Christmas to all, and to all a good holiday weekend. A word of advice: try not to let expectations, your own or those of others, consume you. Try hard (and it is hard work, don’t let anyone tell you otherwise) to be at peace with yourself. Practice it until you’re really good at it. You have a lot of control over your own happiness. I promise! You just have to work at it. In fact, I lately have a lot of hard work to do on this type of thing myself.
And yeah, I’m not a Christian or a Buddhist, so I feel free to cherry-pick the best ideas from all kinds of places :)
Polyglot Persistence (or, really, Database Thaw)
This is a really good article on the rise of NoSQL, and the effects of transitioning. It also notes, as it should, that there are cases when the relational model is still the right one. This will hopefully serve as a reminder to me to pick my coworker’s brain on our new NoSQL architecture that he’s implementing for a specific section of our application.
You Don't Know JavaScript revisited
I thought I would revisit this, since I’ve written a lot of JavaScript this year and I still somehow feel confused by it. Despite the volume of it that I’ve dealt with, I’m still much more at ease server-side. Most of my server-side experience is in PHP, but I’ve never had any great difficulty trying something new, because the concepts are all basically the same, and I understand them well. JavaScript, though, remains something of a mystery to me, so I wanted to see how much I’ve improved over the past eight months or so (if I have at all).
So let’s review. Beginner:
- Knowing the syntax of basic programming tools such as loops, if statements, try/catch, etc.
- Understanding function definitions including the various ways they can be defined and assigned, as well as anonymous functions
- Understanding basic scope principles, global (window) scope versus object scope (closures excluded)
- Understanding the role of context and the use of the ‘this’ variable
- Understanding the different ways to instantiate and declare an object as well as functions as objects
- Understanding JavaScript comparison operators like ‘<’, ‘>’, ‘==’, ‘===’, what is falsy, and how object and string comparison works, as well as casting
- Array indexing for object attributes and functions and how this differs from actual arrays (object literals vs. array literals)
Syntax I have no difficulty with, except for my consistent problem of having to look up the syntax for array and object looping if I’ve been writing in a different language for more than two hours. Compared to last summer, I have a much better understanding of the weird-ass way JS approaches functions, why anonymous functions get used so often, and how all functions are objects and what this means when we assign them and use them. I’m quite happy with understanding scope, context, and ‘this’, although I sometimes have difficulty keeping it in my head correctly and I often have to console.log(this) to remind myself of where I’m at. And I think I’m not the only one who makes scope-related errors now and then; I think it happens to everyone, and it’s just a matter of knowing exactly what went wrong so you can catch it right away (“oh, right, this thing doesn’t know about that thing”). Looping through objects in JS is actually quite nice when you get the hang of it, and the difference between array literals and object literals is, in a lot of ways, kind of a massive chasm. Except that technically arrays are objects. But, you know, array-type objects. This is not that weird in modern languages really, but it’s an important thing to know, because when you want to manipulate something, you really have to know what kind of a thing it is, so that you know how it wants to behave.
Comparison operators in JavaScript are another story, as are truthiness and falsiness. In fact, I’d say it’s a mark of my no longer being a beginner that I see the words “comparison operators” and think, “oooooh, careful, I don’t think I really know that stuff all that well.”
So yeah, I think we can say that I’ve successfully gone beyond beginner-level in JavaScript. Moving on to intermediate:
- Understanding timers, how they work, and when/how they can be useful as well as asynchronous method execution
- In depth knowledge on callbacks and function application such as the ‘call’ and ‘apply’ methods for controlling context and function argument passing
- Understanding JSON notation and the ‘eval’ function
- Understanding closures, how they affect the performance of your code, and how they can be used to create private variables, along with the lovely (function(){})() call
- AJAX and object serialization
Oh, man, timers! I finally learned all about how these work a month or two ago, and got to cement that understanding with a weird little trick my coworker taught me. The same project introduced me to eval(), and why it’s important to avoid evals that happen as an unnecessary extra step. I must admit, though, to some serious ignorance of call() and apply(), and despite having read a whole lot, and asked my coworker for an explanation (and he gave an excellent one that cleared up a lot for me), I am still a little lost with closures. I’ll keep trying. Similarly, serializing is something that I do without understanding it, using helper functions or libraries. I think I have some reading to do.
As for the rest of it, I’m a regular JSON evangelist, and I want everyone in the world to understand that while XML has its place, you should never ever EVER use it in places where you should really be using JSON. I love JSON; I think it’s really elegant, and all the languages I work with have excellent tools for handling it, which makes it a total breeze to parse. The exact opposite of XML, basically. Which, again, does have its place; but if you are just trying to communicate some data back and forth, and it’s got a reasonably simple structure (I’m thinking of, like, most XML APIs I’ve worked with here), you should just be using JSON. Seriously.
And yeah, since everything I do basically involves AJAX, I feel like I have a pretty solid understanding of how it works. I won’t even get into it right now. So, I think we can safely say that I have most of the qualifications for intermediate-level JavaScripting, but I’m still lacking in some key areas. Let’s take a look at advanced:
- Understanding a methods ‘arguments’ variable and how it can be used to overload functions through arguments.length and make recursive calls through arguments.callee. It should be noted that use of arguments.callee can be dangerous as ECMAScript 5 Strict Mode doesn’t support it, although both jQuery (up to 1.4) and Dojo take advantage of it.
- Advanced closures such as self-memoizing functions, currying, and partially applied functions
- Function and html prototyping, the prototype chain, and how to use base JavaScript objects and functions (e.g. Array) to minimize coding
- Object type and the use of instanceof and typeof
- Regular expressions and expression compiling
- With statements and why you shouldn’t use them
- The most difficult part of all, knowing how to tie all these tools together into clean, robust, fast, maintainable, and cross browser compatible code.
Wow! And we just went right the hell over my head with a lot of this stuff. I’ve got some of it; I can implement my crappy-ass regex skills in JavaScript, although I had understood that using compile() was somewhat pointless, as the constructor compiles the expression for you. Oh well. typeof() and instanceof() are basically my lifeblood, and I would be totally non-functional without them, although sometimes on the console they can be maddeningly irritating (“Object object. Well, that was helpful!”). Prototyping is also something that I get to a pretty good degree, which is important, because you (or I, at least, and I think a lot of beginners) would expect it to work like class inheritance in a typical OO language, and it totally doesn’t. I could stand to do some more experimentation with it, though, to get a better understanding.
As for the rest of this, what I understand about the arguments variable includes (a) that it exists, and (b) what it contains for any given function. That’s it. Advanced closures and with statements are pretty much beyond me. And that last item, well … that’s going to be beyond me for a long time yet, I think.
All in all, though, I think I’ve come quite a long way from here. In fact, now I’m in between intermediate and advanced, instead of being between basic and intermediate, which is pretty cool. And another thing that’s happened in the past year is that I noticed different things about this article: like, a lot of the other stuff you really need to know if you’re going to be a good client-side JS coder: the DOM, what it is, and how to manipulate it (an example, by the way, of an excellent use of XML: web pages are too complex and contain to much richness in the metadata, events and everything else tied to each element for this to be effectively described using JSON); and events, how they’re handled in different browsers, and event bubbling all spring to mind.
What a long, strange road it’s been :) All I can say to close this out is that I love what I do.
Molly E. Duggan is proudly powered by
WordPress
Web design by BrightCherry.