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


Groups > comp.lang.javascript > #30386 > unrolled thread

Re: Adding data to a function

Started byAleksandro <aleksandro@gmx.com>
First post2016-05-02 20:30 -0300
Last post2016-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.


Contents

  Re: Adding data to a function Aleksandro <aleksandro@gmx.com> - 2016-05-02 20:30 -0300

#30386 — Re: Adding data to a function

FromAleksandro <aleksandro@gmx.com>
Date2016-05-02 20:30 -0300
SubjectRe: 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.

[toc] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web