Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #30385
| Path | csiph.com!goblin3!goblin1!goblin.stu.neva.ru!uio.no!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!nzpost2.xs4all.net!not-for-mail |
|---|---|
| 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 | Tue, 03 May 2016 00:05:47 +0200 |
| Message-ID | <XnsA5FDFB322EBeejj99@194.109.6.166> (permalink) |
| User-Agent | Xnews/2009.05.01 |
| Lines | 40 |
| NNTP-Posting-Host | 77.174.145.5 |
| X-Trace | 1462226755 dreader36.news.xs4all.nl 4276 ehannivo/77.174.145.5:63186 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.javascript:30385 |
Show key headers only | 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
Re: Adding data to a function "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-05-03 00:05 +0200
csiph-web