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


Groups > comp.lang.javascript > #25852

Re: Use of bind()

From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.javascript
Subject Re: Use of bind()
Date 2014-09-14 11:48 +0200
Organization PointedEars Software (PES)
Message-ID <2263716.JJnVjrgvZp@PointedEars.de> (permalink)
References <df48d594-cbac-4e87-8622-e70c1d6d915d@googlegroups.com> <87bnqjkr2j.fsf@bsb.me.uk>

Show all headers | View raw


Ben Bacarisse wrote:

> […]  The trouble is that the code simply sets a property called isOn on
> the element clicked, rather than the object called "lightbulb".  The
> result is that it seems to work in this simple case.  If you examine the
> value of lightbulb.isOn you will see that it does not change unless you
> use bind (or something similar, of course) and that the HTML element
> suddenly acquires a new property called isOn.

The HTML element _object_ representing the HTML element need not acquire a 
new property.  It is a host object, and augmenting host objects in order to 
use them as data containers, or using their existing properties in an 
unspecified way, is error-prone; it can fail in several ways.
 
-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

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


Thread

Use of bind() enrique.melero@gmail.com - 2014-09-13 15:19 -0700
  Re: Use of bind() Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-09-14 01:01 +0100
    Re: Use of bind() Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-09-14 11:48 +0200
  Re: Use of bind() JJ <jj4public@vfemail.net> - 2014-09-14 11:01 +0700
    Re: Use of bind() enrique.melero@gmail.com - 2014-09-14 00:54 -0700

csiph-web