Reputation: 51
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
var animal = {
type: "mammal"
};
var dog = {
sound: "bark"
};
dog.extends(animal);
alert(dog.type);
});
</script>
The above code is not alerting, and erroring out saying that undefined is not a function. Any idea why?
Upvotes: 0
Views: 410
Reputation: 7246
try this
$(document).ready(function(){
var animal = {
type: "mammal"
};
var dog = {
sound: "bark"
};
$.extend(dog, animal);
alert(dog.type);
});
Upvotes: 3