ga-wdi-boston / js-objects-prototypes Goto Github PK
View Code? Open in Web Editor NEWLicense: Other
License: Other
via @gaand
Tracked here: ga-wdi-boston/js-functions-ins-and-outs#15
Not plural.
In place of this lesson, I delivered this DC lesson instead: https://github.com/ga-wdi-lessons/js-oojs-classes but started at the Classes
section. I hadn't taught this lesson before, but I thought it'd be beneficial for them to have this one delivered because it makes use of ES6 classes. I did go over this http://www.w3schools.com/js/js_object_prototypes.asp with them so they could see how this was previously implemented.
For framing, I talked to them about how I showed them how to make and interact with object literals yesterday, but didn't make a compelling case for object oriented programming and how it makes our code more DRY because we were explicitly defining every civic, camry, mustang, etc. Enter classes, blah, blah, blah.
At this point in DC curriculum, they had a whole lesson on ES6 features so the code here made sense, but then I realized during the lesson that the PVD class hadn't seen template literals before, so I did have to detract a little bit to explain what that is. That's my bad.
Overall, I think the execution of this lesson went surprisingly well. Probably was my favorite so far. This class seemed to understand OOP much more easily than other classes I've seen.
should be this._power (like it is in js-objects-constructors)
I believe last three tests in runs.spec.js
should be expect(user...)
instead of expect(runs...)
'use strict';
// create a new superhero
const Hero = function (name, alias, power) {
this.name = name;
this.alias = alias;
this._power = power;
};
// assigning the new hero's attributes
let superMan = new Hero('Clark Kent', 'Superman', 'faster than a speeding bullet');
let spiderMan = new Hero('Peter Parker', 'Spiderman', 'acts like a spider');
// create a usePower method on the hero prototype (will use the superhero's power that is called)
Hero.prototype.usePower = function () {
return this._power;
};
// create a revealID method on the hero prototype (will reveal the superhero's real name that is called)
Hero.prototype.revealID = function () {
return this.alias + 's real identity is ' + this.name + '!';
};
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.