Understanding the “this” keyword in Javascript

The this keyword always refers to an object.

We can use it outside of any function in the global scope but most often it is used inside a function (otherwise known as a method, when the function is defined inside an object).

When it is used within a method, it refers to the object on which the method is being invoked.

Continue reading “Understanding the “this” keyword in Javascript”

Breaking down a function – updateRecords()

A friend asked me to explain this code in detail for a function called updateRecords() that they were studying on an online learning site. Actually they expect you to create the guts of the function yourself and make sure it meets certain requirements. This is my solution and explanation. It is designed for somewhat beginners so Its deliberately not succinct because the purpose is to explain whats going on in detail in a simple way that is easy to follow. At the end I will demonstrate alternative ways to write the same function in a more concise manner.

Continue reading “Breaking down a function – updateRecords()”

Reconciling Return

The return keyword and its purpose is actually fairly simple but for some reason it seems to cause beginners a lot of confusion. Even after being exposed to it by example and explanation, it can take some time before understanding really sinks in. I know this was certainly the case for me but I don’t believe it needed to be that way. Lets see if we can’t help lessen that confusion here.

Continue reading “Reconciling Return”

Basic Toggling with javascript

If your not familiar with natural javascript and your only used to using a library like jQuery, then you might be surprised to learn that javascript doesn’t have a predefined toggle function that you can just call up when you want. You need to create your own before you can use it. Here is a bare bones demonstration of toggling in plain old ordinary javascript.

Continue reading “Basic Toggling with javascript”

The Definitive Guide to Object-Oriented JavaScript

James Shore has a truly excellent video explaining Javascript Objects and the topic of inheritance in detail at http://www.objectplayground.com/. It covers a few other things and is probably one of the very best videos I’ve seen on the subject. I highly recommend it to anyone who wants to further their knowledge of Javascript.

Here’s a few screenshots: