Coggle requires JavaScript to display documents.
function Person() { this.name = 'Brad'; }
const brad = new Person();
function Person(name) { this.name = name; }
const brad = new Person('brad');
this.name = name;
this.calculateAge = function () { ... };
const name1 = 'Jeff';
const name2 = new String('Jeff');
const getSum1 = function(x, y){ ... }
const getSum2 = new Function('x','y', ... );
const john1 = {name: "John"};
const john2 = new Object({name: "John"});
const arr1 = [1,2,3,4];
const arr2 = new Array(1,2,3,4);
const john = new Person('John', 'Doe', '8-12-90');
console.log(john);
__proto__
Person.prototype
Person.prototype.calculateAge = function(){ ... }
john.calculateAge())
Person.prototype.getFullName = function(){ ... }
Person.prototype.getsMaried = function(newLastName){ ... }
function Person(firstName, lastName) { ... }
Person.prototype.greeting = function(){ ... }
const person1 = new Person('John', 'Doe');
function Customer(firstName, lastName, phone, membership) { ... }
Person.call(this, firstName, lastName);
Customer.prototype = Object.create(Person.prototype);
Customer.prototype.constructor = Customer;
Customer.prototype.greeting = function(){ ... }
Object.create()
const personPrototypes = { ... }
greeting: function() { ... },
getsMarried: function(newLastName) { ... }
const mary = Object.create(personPrototypes);
const brad = Object.create(personPrototypes, { ... }
firstName: {value: 'Brad'},
mary.firstName = 'Mary';
mary.getsMarried('Thompson');
class Person ( ) {...}
constructor (firstName, lastName) { ... }
this.firstName = firstName
greeting() { ... }
calculateAge() { ... }
static addNumbers(x, y) { ... }
Person.addNumbers(1,2)
class Person () { ... }
class Customer extends Person { ... }
constructor(firstName, lastName, phone, membership) { ... }
static getMembershipCost() { ... }
super(firstName, lastName);
this.phone = phone; this.membership = membership;