L
Lobo
I'm wondering how expensive and (in)efficient is to use Collection
type javascript library functions (similar to using Blocks), instead
of repeating the 'for' iterator over and over across a large
application.
I'm afraid that instantiating javascript Functions to act as Blocks in
these cases might require many more internal javascript resources
(time / memory) compared to using the 'for' statement - ?.
I would not want this to be the cause for my apps to eventually run
much slower (and consuming more memory).
For reference, define the following Collection type javascript
function:
function array_do (theArray, theBlock) {
for (var i=0; i<theArray.length; i++) {
var eachElement = theArray;
theBlock(eachElement);
}
}
.... and use it as follows:
array_do (testArray, function(each) { ... do something with
'each' ... } );
As you can see I would have to create a new javascript function each
time I need to execute the array_do function.
Thanks in advance.
type javascript library functions (similar to using Blocks), instead
of repeating the 'for' iterator over and over across a large
application.
I'm afraid that instantiating javascript Functions to act as Blocks in
these cases might require many more internal javascript resources
(time / memory) compared to using the 'for' statement - ?.
I would not want this to be the cause for my apps to eventually run
much slower (and consuming more memory).
For reference, define the following Collection type javascript
function:
function array_do (theArray, theBlock) {
for (var i=0; i<theArray.length; i++) {
var eachElement = theArray;
theBlock(eachElement);
}
}
.... and use it as follows:
array_do (testArray, function(each) { ... do something with
'each' ... } );
As you can see I would have to create a new javascript function each
time I need to execute the array_do function.
Thanks in advance.