M.O.S. Studios Posted June 16, 2011 Share Posted June 16, 2011 I made this function, now it appears when ever i do a "for ... in". How do I attach it to the array object with out attaching it to all the instances Array.prototype.leap = function(){ var y = this; y.shift(); return y; } Quote Link to comment https://forums.phpfreaks.com/topic/239569-prototypes/ Share on other sites More sharing options...
gizmola Posted June 16, 2011 Share Posted June 16, 2011 When you make something part of the prototype, you are making it part of all instances. The Prototype is roughly equivalent to a class definition in javascript. Quote Link to comment https://forums.phpfreaks.com/topic/239569-prototypes/#findComment-1230695 Share on other sites More sharing options...
M.O.S. Studios Posted June 16, 2011 Author Share Posted June 16, 2011 thanks Quote Link to comment https://forums.phpfreaks.com/topic/239569-prototypes/#findComment-1230701 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.