JavaScript Constructors

Have you used JavaScript constructors before? At first look you may think they are similar to classes in Java. JavaScript constructors imitate the pattern, but they still use the prototypal inheritance that is a huge part of JavaScript.

You need to be able to understand constructors completely in order to use them fully. Constructors have some unique traits.

A couple of weeks ago on our YouTube channel, I released a tutorial that covers 5 important concepts about constructors. If you haven’t used constructors extensively or are just getting started with them, you might find the tutorial very useful. At least I hope you do.

JavaScript Questions

Today we started a new series on the All Things JavaScript YouTube channel. We call it JavaScript Questions.

Now, I know we have been addressing questions the whole time, so this series doesn’t take us too far away from what we were already doing. In this series we just want to address some of the common JavaScript questions that are out there.

For the first video, we address the question: What is hoisting? We are starting out with a simple but common question for those that are somewhat new to JavaScript.

It is important to address terms that are thrown around the JavaScript world. The more terms you understand, the better you can communicate about JavaScript. Terms also help you compartmentalize your knowledge as you learn more and more about JavaScript. Hoisting is one of those terms and it is a concept that is fairly unique the JavaScript.

If you would like to delve into the question of hoisting, you can watch the video below.

What other common JavaScript questions should we address?

A Little Over 200 Pages, but a Wealth of Information

I did a review a couple of months ago about my favorite book on JavaScript. This review is on another favorite of mine: JavaScript Patterns by Stoyan Stefanov.

Stoyan begins the book by describing programming patterns as solutions to common problems. Patterns are not necessarily code that you can copy and paste, but more of a best practice solution.

Stoyan is very thorough in the patterns he presents. He begins with basic patterns, which are as simple as how you write your code. He goes on to address literals and constructors, functions, object creation patterns, code reuse patterns, design patterns and DOM patterns. With certain patterns he presents multiple approaches.

I have adopted several of the patterns that I have read about in this book, but more importantly than the patterns I’ve adopted are the things I have learned. Stoyan explains the problems that create the need for a pattern and the reasons behind certain patterns. I found myself learning an immense amount from these explanations. They are real world problems with real world explanations.

This book is definitely one of my favorites. Can I have two favorites?

If you haven’t read this book yet, I highly recommend it. Not only for the patterns presented, but for the information you can learn about JavaScript.

Using Concise Methods

It is time for another article on an ES6 feature. ES6 contained so many new features, it could take months to write about them all, but today I chose to write about concise methods. I love to save on typing.

When you define an object using object literal notation, you would traditionally set up a method as shown here:

var obj = {
fullName: function() {
console.log(“This is a method”);

ES6 provides a more concise syntax for doing this. It saves on typing and who doesn’t like to save some typing? Basically, the concise method allows the removing of the function keyword and the colon. The same object definition would look like this using the concise method:

var obj = {
fullName() {
console.log(“This is a method”);

This ES6 feature is supported by modern version of all major browsers. On the mobile side it is also well supported by iOS. Android’s support is not as strong, so you may want to limit your use of this feature to desktop implementations.

ES6 provides several syntax changes that follow this concise pattern. What is your favorite?

Book Review: The Principles of Object-Oriented JavaScript

For my first entry of the new year, I would like to do a book review. I have been reading The Principles of Object-Oriented JavaScript by Nicholas C. Zakas for several weeks now.

I was attracted to this particular book because of the promise in the title. I’m always wanting to learn new concepts about how to use JavaScript to the fullest and the object-oriented nature of JavaScript, I feel, is one of its more powerful features.

The book is a pretty quick read. It is less than 100 pages even if you count the index. So it targets a very specific topic.

I found it to have some good information on objects, constructors and prototypes. It also addresses inheritance very well. However, where I felt a little let down is with its application. It does include some object patterns, but I was looking for more. I wanted to see more about how to apply the object-oriented nature of JavaScript to coding.

Despite the fact that it is missing some of that application, I still think it is a great book that will help you better understanding objects and prototypal inheritance in JavaScript. It delves into some little understood features of objects. So if you are looking to expand your knowledge of object-oriented programming in JavaScript and the nature of objects, you may want to pick up this quick read.