Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
<!--[if IE]>
  <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style>
  article, aside, figure, footer, header, hgroup, 
  menu, nav, section { display: block; }
</style>
</head>
<body>
  <p id="hello">Hello World</p>
</body>
</html>
 
/**
* Author: Ruben Oliveira from Teameffort.pt
*/
function Person() { // base class
    this.sayHello = function (){
        alert ('Hello!'); 
    }
    this.sayBy = function (){
        alert ('Good By!'); 
    }
    this.ocupation = function(){} // this method doesn't need to be declared. but for illustration let's keep it here.
}
function Student(){ // class that will extend Person class
    this.ocupation = function (){ // override ocupation method
        alert ("I'm a student!");
    }
    this.workExperience = function (){
        alert("I have no work experience cause... I'm a student!");
    }
}
Student.prototype = new Person(); // inherit from Person
function Worker(){ // another impl of Person...
    this.ocupation = function (){
        alert ("I'm a worker!");
    }
    this.workExperience = function (){
        alert("I have 20 years of work experience!");
    }
}
Worker.prototype = new Person();
var student = new Student();
student.sayHello();
student.ocupation();
student.workExperience();
student.sayBy();
var worker = new Worker();
worker.sayHello();
worker.ocupation();
worker.workExperience();
worker.sayBy();
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers