Created
November 17, 2013 00:03
-
-
Save jocoonopa/7507112 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="zh-tw"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Javascript函式獨立性</title> | |
</head> | |
<body> | |
</body> | |
<script> | |
function Person ( name, age, sex ) { | |
this.name = name; | |
this.age = age; | |
this.sex = sex; | |
this.getInfo = function () { | |
console.log( this.name + this.age + this.sex ); | |
}; | |
} | |
var jocoonopa = new Person ( 'jocoonopa', 27, 'male' ); | |
jocoonopa.getInfo(); | |
function Animal ( name, sex, weight ) { | |
this.name = name; | |
this.sex = sex; | |
this.weight = weight; | |
} | |
var Piggy = new Animal ( '豬豬', '女生', '100公斤' ); | |
jocoonopa.getInfo.call( Piggy ); | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment