Unit 6. Classes

JavaScript is an object-oriented language. Except for a few primitives, most values in JavaScript, even functions, are objects. Most of the JavaScript code that gets written is for creating custom objects. Many times you’re probably building your own objects from scratch, but sometimes you’ll be starting from a base object provided from a framework or library and adding custom functionality to it. Unfortunately, there hasn’t been a clear way for library authors to provide a base object prototype that can be extended by application developers. This has left many library authors needing to reinvent the wheel.

But nobody reinvents the wheel the same way. Here’s how Backbone.js provides a way to extend base objects:

Backbone.Model.extend({ ...

Get Get Programming with JavaScript Next now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.