SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict ketting00's Avatar
    Join Date
    Jul 2011
    Posts
    325
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    How to use prototype in this function

    I've no idea how to get it works, or is it possible at all.
    Code:
    var x = 'Test Test Test';
    
    var y = {
    	z: function(i) {
    		this.i = i;
    		this.a(i);
    	},
    	a: function(b) {
    		this.b = b;
    		this.c(b);
    	}
    	a.prototype = {
    		c: function() {
    			console.log(this.b);
    		}
    	}
    }
    y.z(x);
    Thank you,

  2. #2
    SitePoint Addict ketting00's Avatar
    Join Date
    Jul 2011
    Posts
    325
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Never mind. I get it worked.
    Code:
    var x = 'Test Test Test';
    
    var y = {
    	z: function(i) {
    		this.i = i;
    		this.a(i);
    	},
    	a: function(b) {
    		var that = this;
    		this.b = b;
    		this.a.prototype = function(b) { that.d(b); }
    		var c = this.a.prototype(b);
    	},
    	d: function(e) {
    		this.e = e;
    		console.log(e);
    	}
    }
    
    y.z(x);


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •