Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #30385

Re: Adding data to a function

Newsgroups comp.lang.javascript
Subject Re: Adding data to a function
From "Evertjan." <exxjxw.hannivoort@inter.nl.net>
References <Adding-data-20160502223342@ram.dialup.fu-berlin.de>
Date 2016-05-03 00:05 +0200
Message-ID <XnsA5FDFB322EBeejj99@194.109.6.166> (permalink)

Show all headers | View raw


ram@zedat.fu-berlin.de (Stefan Ram) wrote on 02 May 2016 in 
comp.lang.javascript:

>   The following function always would recompute 
>   Żwindow.document.getElementById( "info" )Ž.
> 
> "use strict";
> 
> function f()
> { window.document.getElementById( "info" ).innerHTML 
>   = 'The function "f" was called.'; }
> 
>   Is it good style to attach this data to f as a property of f,
>   so that it does not have to be recomputed each time f is
>   being called, i.e.: [....]

Methinks "Is it good style to ... ?" 
is not a good question,
as it calls for subjective preferences 
like "is this a beautiful painting?"

You could ask:
"Is it clearer scripting sourcecode for newbees?"
or
"Does this involve less cpu-time?"

Methinks, the clearer code Q is important, sometimes.

The cpu-time consumption is not, as:

- how many times would you want an innerHTML to change per second?

- the difference in fetching a DOM-pointer from a DOM id-array or as an 
object-property [or even as a simple variable] will not matter much imho, 
but you could try to measure that for different browsers, if you like.

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Back to comp.lang.javascript | Previous | Next | Find similar | Unroll thread


Thread

Re: Adding data to a function "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-05-03 00:05 +0200

csiph-web