Created
June 27, 2012 00:21
-
-
Save rubyonrailstutor/3000426 to your computer and use it in GitHub Desktop.
prototype in js description
This file contains 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
<html> | |
<head> | |
<script type="text/javascript"> | |
if (typeof Object.create !== 'function') { | |
Object.create = function (o) { | |
var F = function () {}; | |
F.prototype = o; | |
return new F(); | |
}; | |
}; | |
var parent = { | |
first_name: "john", | |
last_name: "davison" | |
}; | |
var child = Object.create(parent); | |
child.hobby = "skating" | |
child.first = "johnny" | |
function check_relationship(){ | |
var parent = { | |
first_name: "mike", | |
last_name: "someone" | |
}; | |
var child = Object.create(parent); | |
child.hobby = "surfing" | |
child.first = "baby mike" | |
alert("the parent is" + " " + child.first_name + " " + child.last_name + ", " + child.first + " " + "is the first child") | |
} | |
</script> | |
</head> | |
<body> | |
<form> | |
<input type="submit" value="check_relationship" onclick="check_relationship()"> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment