Byte-Sized-Chunks: Dynamic Prototypes in Javascript

Master Javascript's way of doing inheritance - via Dynamic Prototypes!
4.8 (2 ratings)
Instead of using a simple lifetime average, Udemy calculates a
course's star rating by considering a number of different factors
such as the number of ratings, the age of ratings, and the
likelihood of fraudulent ratings.
11 students enrolled
25% off
Take This Course
  • Lectures 24
  • Length 3 hours
  • Skill Level All Levels
  • Languages English
  • Includes Lifetime access
    30 day money back guarantee!
    Available on iOS and Android
    Certificate of Completion
Wishlisted Wishlist

How taking a course works


Find online courses made by experts from around the world.


Take your courses with you and learn anywhere, anytime.


Learn and practice real-world skills and achieve your goals.

About This Course

Published 3/2016 English

Course Description

Note: This course is a subset of our much longer course 'Learn By Example: HTML, CSS and Javascript' so please don't sign up for both:-)

Javascript objects, prototypes and JSON - that's what this course is about.

This is not a course on Javascript frameworks - its about solid, fundamental Javascript. You'll be surprised by how much more you can get done on your web pages once you learn these technologies the right way.

What do we mean by that?

  • Relatively few folks formally learn HTML, CSS or Javascript, because its quite easy to get stuff done in these technologies in a "quick-and-dirty way".
  • That "quick-and-dirty" way of learning and doing leads to problems over time, because Javascript and CSS are actually quite complex, so it is easy to do things the wrong way
  • This course will help, because it is entirely built atop examples. Each is self-contained, has its source code attached, and gets across a simple, specific use-case. Each example is simple, but not simplistic.

What's Included:

  • Prototypes are Javascript's way of doing inheritance, and its very different from the C++/Java way of doing it.
  • JSON is not conceptually difficult to use, but it is incredibly important, and you should understand why - because its the glue between backends written in Java or other traditional languages, and front-ends written in Javascript
  • The Document-Object-Model is what ties Javascript back to HTML and CSS. Together with JSON, the DOM ties it all together from server to skin.

Talk to us!

  • Mail us about anything - anything! - and we will always reply :-)

What are the requirements?

  • Any modern browser and a simple text editor are all that will be needed for the code examples
  • Some prior programming experience will definitely help!

What am I going to get from this course?

  • Master inheritance in Javascript
  • Understand what dynamic prototyping is, and its benefits and pitfalls
  • Understand the use-cases for prototyping and inheritance

Who is the target audience?

  • Nope! Please don't enroll for this class if you have already enrolled for our 13-hour course 'Foundations of HTML, CSS and Javascript' course
  • Yep! Folks who are seeking to learn Javascript the right way - including folks who may done some Javascript programming, but are not quite confident using advanced features such as dynamic prototyping
  • Nope! This class is not right for you if you are looking to learn Javascript frameworks such as JQuery, Angular or Node.js

What you get with this course?

Not for you? No problem.
30 day money back guarantee.

Forever yours.
Lifetime access.

Learn on the go.
Desktop, iOS and Android.

Get rewarded.
Certificate of completion.


Section 1: A Different Take on Objects
You, This Course, and Us!
Javascript objects are very different from C++ and Java objects! It's quite a paradigm change if you've programmed in other languages before.
JSON can be used as a textual representation of a JS object. You can construct an object using JSON notation.
Object constructors are just functions with two specific differences. The use of the magical keyword "this" within the constructor and the use of the magical keyword "new" to create an object from the constructor
You can add properties to an object after it's been constructed on the fly! Pretty mind-bending for programmers from other object oriented languages.

You can also remove properties from objects after they have been constructed. Again not allowed in traditional object oriented languages!

Functions are first class citizens in Javascript which means that object properties can be function as well.
Object properties defined in constructors can be functions as well! Again because functions are first class citizens.

Properties of objects can be accessed using the dot "." notation as well as the square brackets "[]" notation. They are essentially the same.

A special for loop exists to loop over object properties. Every object supports this thanks to the base Object class!
Bad things happen when you call an object constructor without the new keyword.
The typeof operator tells you whether a variable is a number, string, object or undefined. It cannot differentiate between different types of objects though.
Use the instanceof operator to figure out what constructor was used to create an object. This only recognizes where the object came from, it does not know what changes were made to the object after it was constructed.
Properties are public by default, however it's often useful to have private properties. These are not natively supported in JS but we can fake them.
Javascript supports inheritance, but it does so in a very different way - using prototypes. The key is the prototype property that all object constructors possess. How can a function have a property? Why, because functions are objects of course!
Let's plunge into our first example of prototypical inheritance, and understand the prototype keyword.
An object's prototype can change on the fly - this is called Dynamic Prototyping, and this can lead to some pretty surprising effects in Javascript
A chain of inheritance can be implemented via prototypes - the Javascript interpreter will walk up the hierarchy until it can resolve a property.
You can use the prototype keyword to override a property of all objects! Its a lot more powerful than simply overriding a property on a single object.
Javascript has a prototype Object, from which all objects derive. In this sense its exactly like Java (of course the mechanism of inheritance is very different in Javascript)
Did you know that its possible to override properties even of built-in object types, such as strings? Do so with care!
JSON is a simple way to create an object from a string. Its full power lies in its simplicity, and in the fact that server-side code, which maybe in Java or C++, can communicate with a client in Javascript. This is huge.
JSON can be used to create virtually anything - strings, numbers, booleans, empty objects, arrays.
JSON can be used to create arbitrarily complex objects - see how.

Students Who Viewed This Course Also Viewed

  • Loading
  • Loading
  • Loading

Instructor Biography

Loony Corn, A 4-person team;ex-Google; Stanford, IIM Ahmedabad, IIT

Loonycorn is us, Janani Ravi, Vitthal Srinivasan, Swetha Kolalapudi and Navdeep Singh. Between the four of us, we have studied at Stanford, IIM Ahmedabad, the IITs and have spent years (decades, actually) working in tech, in the Bay Area, New York, Singapore and Bangalore.

Janani: 7 years at Google (New York, Singapore); Studied at Stanford; also worked at Flipkart and Microsoft

Vitthal: Also Google (Singapore) and studied at Stanford; Flipkart, Credit Suisse and INSEAD too

Swetha: Early Flipkart employee, IIM Ahmedabad and IIT Madras alum

Navdeep: longtime Flipkart employee too, and IIT Guwahati alum

We think we might have hit upon a neat way of teaching complicated tech courses in a funny, practical, engaging way, which is why we are so excited to be here on Udemy!

We hope you will try our offerings, and think you'll like them :-)

Ready to start learning?
Take This Course