Skip to content

Instantly share code, notes, and snippets.

@octosteve
Created November 10, 2014 20:44
Show Gist options
  • Save octosteve/93b273cef5e23354d1c0 to your computer and use it in GitHub Desktop.
Save octosteve/93b273cef5e23354d1c0 to your computer and use it in GitHub Desktop.
Notes from Objects In Javascript talk
// School, Student, Course
// function communicateSlogan(){
// return this.name + " : " + this.slogan;
// }
//
// var flatiron = {
// name: "The Flatiron School",
// slogan: "Learn to program, and pick locks",
// saySlogan: communicateSlogan
// };
//
// var taft = {
// name: "Taft",
// slogan: "Try not to get shot",
// saySlogan: communicateSlogan
// };
// function Student() {
// }
// var student = new Student();
// function Student(name) {
// this.name = name;
// // no return value?!??!
// }
// var student = new Student("Steven");
// console.log(student.name); // returns name
// use strict
// function Student(name) {
// this.name = name;
// this.greet = function(){
// console.log("Hi! I'm " + this.name);
// }
// }
//
// var steven = new Student("Steven");
// steven.greet();
//
// var tristan = new Student("Tristan");
// tristan.greet();
// var flatiron = {
// name: "The Flatiron School",
// slogan: "Learn to program, and pick locks",
// saySlogan: communicateSlogan
// };
//
// var taft = {
// name: "Taft",
// slogan: "Try not to get shot",
// saySlogan: communicateSlogan
// };
"use strict";
function School(name, slogan){
this.name = name;
this.slogan = slogan;
}
School.prototype.saySlogan = function(){
console.log(this.name + " : " + this.slogan);
}
var flatiron = School("The Flatirion School", "Learn code and improv");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment