-1

I have been reading some code and found a line of code which looked like this:

ApplyEffects[filterButton.id](originalPhoto, 'jpeg');

I have never seen what I assume is a function called like this and searched google but can't find out what it means. In the code also there is no function called ApplyEffects or any variables called ApplyEffects, just this one line of code. I thought it could be a mistake so I commented out this line and the code stops working so it serves a purpose, but I have never seen this syntax before and am unsure what it does. What do these brackets mean?

UPDATE: Sorry I found out there is an array variable called ApplyEffects.

Blazemonger
  • 90,923
  • 26
  • 142
  • 180
user2924127
  • 6,034
  • 16
  • 78
  • 136
  • ApplyEffects is an object, the brackets just form a path, and the function is normal. if filterButton.id was "one", then the line is the same as `ApplyEffects.one(originalPhoto, 'jpeg');` – dandavis Jul 15 '15 at 20:13

1 Answers1

2

ApplyEffects is an array that contains a function in position filterButton.id. Square brackets are used to get a specific array element in this case.

Claudio Redi
  • 67,454
  • 15
  • 130
  • 155
  • 1
    i would assume that _filterButton_ is an element, and elements can't use numerical-only IDs, and Arrays shouldn't use valid IDs as iterable keys, so it's more likely an Object, not an Array. – dandavis Jul 15 '15 at 20:16
  • You can access named properties in the same way so `ApplyEffects` may not be an array. – Mike Cluck Jul 15 '15 at 20:17
  • Yes, definitively didn't word this correctly but he already stated that he has an array variable called `ApplyEffects` so don't think it's worth to expand my answer – Claudio Redi Jul 15 '15 at 20:19