0

I'm writing my own JavaScript library. How can I do for extend my object in this way?

_.mymethod();

Here's my code:

(function (window, undefined) {
    "use strict";

    var emptyArray = [];

    function _(id) {
        return new _.fd.init(id);
    }

    _.fd = _.prototype = {
        init: function (selector) {
            this.el = document.getElementById(sel);
            return this;
        },
        replaceText: function (text) {
            this.el.innerHTML = text;
            return this;
        },
        changeTextColor: function (color) {
            this.el.style.color = color;
            return this;
        }
    };

    _.fd.init.prototype = _.fd;
    _.extend = function (target) {};
    _.extend({});

    window._ = _;
}(window));

The point is, how to extend for using method like

_.method();
Ste
  • 1,497
  • 8
  • 33
  • 63

0 Answers0