- Joined
- Jan 29, 2014
- Messages
- 11
- Reaction score
- 2
- First Language
- English
- Primarily Uses
Hello all,
I have two code examples below that describe my confusion, and questions about each example:
1) this._data = $gameParty.allItems().filter(function(item)
Okay, #1, I get that $gameparty.allitems concatenates the various item arrays to make one large array, and the .filter sifts through the array...but what in the bleep is the function being called there mean? My confusion stems from testing the code with alert(item); and getting NULL as a response or in some cases with similar code some error.
#2, I understand that for each member of the party, some code needs to execute, but like above, actor doesn't exist as a variable...how can a function be passed a parameter that doesn't exist? Furthermore, what is "this" at the end of the function declaration?
I am not familiar with this style of programming, and all the research I do leaves me with more questions than I had before; so I am at y'all's mercy. My main questions about both snippets above is what is that function reference called? How can a parameter be sent to a function that doesn't exist? and why is "this" in there? is it binding something to this particular function?
Thank you for your help, and I apologize in advance if these questions have come up in the past.
Gatene
I have two code examples below that describe my confusion, and questions about each example:
1) this._data = $gameParty.allItems().filter(function(item)
Code:
2) $gameParty.members().forEach(function(actor) {
ImageManager.loadFace(actor.faceName());
}, this);
Okay, #1, I get that $gameparty.allitems concatenates the various item arrays to make one large array, and the .filter sifts through the array...but what in the bleep is the function being called there mean? My confusion stems from testing the code with alert(item); and getting NULL as a response or in some cases with similar code some error.
#2, I understand that for each member of the party, some code needs to execute, but like above, actor doesn't exist as a variable...how can a function be passed a parameter that doesn't exist? Furthermore, what is "this" at the end of the function declaration?
I am not familiar with this style of programming, and all the research I do leaves me with more questions than I had before; so I am at y'all's mercy. My main questions about both snippets above is what is that function reference called? How can a parameter be sent to a function that doesn't exist? and why is "this" in there? is it binding something to this particular function?
Thank you for your help, and I apologize in advance if these questions have come up in the past.
Gatene

