-
-
Save mannuelf/b55b3136e7568ed16b6135315f7db9a9 to your computer and use it in GitHub Desktop.
Extend Demo // source http://jsbin.com/solige
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="https://code.jquery.com/jquery-2.1.4.js"></script> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>Extend Demo</title> | |
</head> | |
<body> | |
<h1>Extend Demo</h1> | |
<script id="jsbin-javascript"> | |
var animals = { | |
actions: { | |
eat: function() { console.log('animal says: Im eating'); }, | |
sit: function() { console.log('I\'m Sitting'); } | |
} | |
}; | |
var dog = { | |
actions: { | |
bark: function() { console.log('dog: Im Barking woof woof'); }, | |
dig: function() { console.log('dog: Im digging'); } | |
} | |
}; | |
dog.actions.bark(); | |
dog.actions.dig(); | |
$.extend(dog, animals); | |
dog.actions.eat(); | |
dog.actions.sit(); | |
console.log(dog.actions.bark); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">var animals = { | |
actions: { | |
eat: function() { console.log('animal says: Im eating'); }, | |
sit: function() { console.log('I\'m Sitting'); } | |
} | |
}; | |
var dog = { | |
actions: { | |
bark: function() { console.log('dog: Im Barking woof woof'); }, | |
dig: function() { console.log('dog: Im digging'); } | |
} | |
}; | |
dog.actions.bark(); | |
dog.actions.dig(); | |
$.extend(dog, animals); | |
dog.actions.eat(); | |
dog.actions.sit(); | |
console.log(dog.actions.bark);</script></body> | |
</html> |
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
var animals = { | |
actions: { | |
eat: function() { console.log('animal says: Im eating'); }, | |
sit: function() { console.log('I\'m Sitting'); } | |
} | |
}; | |
var dog = { | |
actions: { | |
bark: function() { console.log('dog: Im Barking woof woof'); }, | |
dig: function() { console.log('dog: Im digging'); } | |
} | |
}; | |
dog.actions.bark(); | |
dog.actions.dig(); | |
$.extend(dog, animals); | |
dog.actions.eat(); | |
dog.actions.sit(); | |
console.log(dog.actions.bark); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment