Matthew Bramer wrote:
> Thanks guys for the feedback and that article has a bunch of #Awesomesauce
> in it.
>
> If memory considerations are minimal, then I'll just have to use that post
> as guidance.  Anyone have any more insight on the difference in memory
> usage?  I'm pressing that issue b/c we have to code for bare minimal
> machines, so any little trick I can use goes a long way.

This seems like classic premature optimisation. Passing an object
should use more memory because an object is created whose properties
will be accessed and probably assigned to local variables anyway. But
I expect that the difference in memory use is absolutely minimal.

If your target platform is so minimal that such tricks are required,
you've likely got far bigger issues to deal with. Just code to
whatever suits (previous posts cover the obvious scenarios) and  then,
*if* you have an issue, deal with it.

There is no difinitive answer. Just to put another iron in the fire...

It may seem suitable to use an object where you have a large number of
parameters with many that are optional (e.g. a generic "createElement"
function). But you might also consider having a small number of
parameters (say tagName and optional id) and adding the extra
properties in the caller. Whatever logic was used in the caller to
create the object to pass as a parameter can also be used in the
caller to add properties directly on the returned object. Naturally
that won't suit every case, but it is another approach.

So there is more than one way to skin a cat, it's just a matter of
what suits best at the time. Memory use is unlikely to be a factor in
considering how to pass parameters.


--
Rob

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to