JSFiddle - React, Tailwind, and code Playground

by the_archer

JavaScript

Person = Backbone.Model.extend({
    defaults: {
        name: 'Fetus',
        age: 0,
        children: []
    },
    initialize: function() {
        alert("Welcome to this world");
    },
    adopt: function(newChildsName) {
        var children_array = this.get("children");
        children_array.push(newChildsName);
        this.set({
            children: children_array
        });
    }
});

var person = new Person({
    name: "Thomas",
    age: 67,
    children: ['Ryan']
});
person.adopt('John Resig');
console.log(person);
var children = person.get("children"); // ['Ryan', 'John Resig']