Skip to content

Instantly share code, notes, and snippets.

@kenrett
Created September 2, 2017 00:56
Show Gist options
  • Save kenrett/9b0f6f025f2c554c2b308eeb14b5b571 to your computer and use it in GitHub Desktop.
Save kenrett/9b0f6f025f2c554c2b308eeb14b5b571 to your computer and use it in GitHub Desktop.
OOJS Breakout
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Coolest breakout ever</title>
</head>
<body>
<h1>Words</h1>
<script src="person.js"></script>
</body>
</html>
// Semicolons:
// 1 - setting variables
// 2 - function calls
// 3 - returns
// 4 - prototypes
// Object Literal
// var person1 = {
// firstName: "John",
// lastName: "Elway",
// fullName: function(){
// return this.firstName + " " + this.lastName;
// }
// };
// console.log("john", john.fullName());
// Constructor Functions
// class Person
// def initialize(first_name, last_name)
// @first_name = first_name
// @last_name = last_name
// end
// end
var Person = function(firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
this.fullName = function(){
return this.firstName + " " + this.lastName;
}
};
// Person.prototype.fullName = function () {
// return this.firstName + " " + this.lastName;
// };
// hugo = Person.new("hugo", "boss")
var hugo = new Person("Hugo", "Chen");
console.log(hugo.fullName());
// var leah = new Person("Leah", "Brady");
// var person = new Person("Poop", "Brady");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment