Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #30386 > unrolled thread
| Started by | Aleksandro <aleksandro@gmx.com> |
|---|---|
| First post | 2016-05-02 20:30 -0300 |
| Last post | 2016-05-02 20:30 -0300 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.javascript
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Adding data to a function Aleksandro <aleksandro@gmx.com> - 2016-05-02 20:30 -0300
| From | Aleksandro <aleksandro@gmx.com> |
|---|---|
| Date | 2016-05-02 20:30 -0300 |
| Subject | Re: Adding data to a function |
| Message-ID | <ng8noh$qtg$1@dont-email.me> |
On 02/05/16 18:39, Stefan Ram wrote:
> 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.:
>
> "use strict";
>
> function f()
> { f.info.innerHTML
> = 'The function "f" was called.'; }
> f.info = document.getElementById( "info" );
>
> ?
If the object is ever destroyed and a new one with the same ID appears,
your function will never see it.
Back to top | Article view | comp.lang.javascript
csiph-web