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


Groups > comp.lang.javascript > #26633

Re: quick question: how to dynamically an image source file?

From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.javascript
Subject Re: quick question: how to dynamically an image source file?
Date 2015-01-20 14:06 +0100
Organization PointedEars Software (PES)
Message-ID <1894285.eRrXKrdmPT@PointedEars.de> (permalink)
References <9607d1f5-10c0-4703-901c-bab1932cb04a@googlegroups.com> <XnsA427734C3E58Ceejj99@194.109.133.133> <m9iue0$bah$1@speranza.aioe.org> <6abe327d-c487-4e03-8a6f-f7f65ebc8bb0@googlegroups.com> <14epavonqlnzl.2wklfi1o8grp.dlg@40tude.net>

Show all headers | View raw


JJ wrote:

> If you use !b and b is not yet declared, the JavaScript engine will try to
> retrieve b variable's value, fail, then stop the execution.

This statement does not make a lot of sense.

It is only possible to “not yet declare” an identifier when using eval() and 
not in strict mode. [1]  Other declarations in an execution context are 
processed *before* execution of the statements in that context begins. [2]

The “JavaScript engine” (the ECMAScript implementation) will _not_ “try to 
retrieve b variable's value”; it does not even "know" at this point 
*whether* the identifier is referring to a variable.

Instead, the identifier “b” is resolved.  This is done according to the 
current *scope chain*.  If no other object is in the scope chain before it 
(per the “with” statement in non-strict mode), the Variable Object of the 
same execution context (ES 1 to 3 Final), or the Variable Declaration 
Binding (ES 5.x) will be checked against.  If no such name can be found 
there, i. e. the next object in the scope chain does not have a property of 
that name, lookup will continue along the scope chain until is end is 
reached, [3] at which usually is the Global Object (not in eval code in 
strict mode [1]).

If the last object in the scope chain still does not have such a property, 
execution does _not_ simply fail.  Instead, a ReferenceError exception is 
thrown at the line of the originating code [4] which can be caught in the 
respective execution context and calling execution contexts [5] by a try–
catch(–finally) statement [6].  Only if the exception is not caught, 
execution of the program terminates, returning the exception referred to by 
“e” as part of the abrupt completion “(throw, e, empty)”. [7]

_____________
[1] <http://ecma-international.org/ecma-262/5.1/#sec-10.4.2>
[2] <http://ecma-international.org/ecma-262/5.1/#sec-10.3>
[3] <http://ecma-international.org/ecma-262/5.1/#sec-10.3.1>
[4] <http://ecma-international.org/ecma-262/5.1/#sec-8.7.1>
[5] <http://ecma-international.org/ecma-262/5.1/#sec-5.2>
[6] <http://ecma-international.org/ecma-262/5.1/#sec-12.14>
[7] <http://ecma-international.org/ecma-262/5.1/#sec-12.1>
-- 
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

quick question: how to dynamically an image source file? justaguy <lichunshen84@gmail.com> - 2015-01-18 19:39 -0800
  Re: quick question: how to dynamically an image source file? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-01-19 11:20 +0100
    Re: quick question: how to dynamically an image source file? Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2015-01-19 10:48 -0200
      Re: quick question: how to dynamically an image source file? justaguy <lichunshen84@gmail.com> - 2015-01-19 07:52 -0800
        Re: quick question: how to dynamically an image source file? JJ <jj4public@vfemail.net> - 2015-01-20 02:47 +0700
          Re: quick question: how to dynamically an image source file? justaguy <lichunshen84@gmail.com> - 2015-01-19 14:24 -0800
            Re: quick question: how to dynamically an image source file? JJ <jj4public@vfemail.net> - 2015-01-20 07:31 +0700
              Re: quick question: how to dynamically an image source file? justaguy <lichunshen84@gmail.com> - 2015-01-20 02:26 -0800
            Re: quick question: how to dynamically an image source file? Tim Streater <timstreater@greenbee.net> - 2015-01-20 12:08 +0000
              Re: quick question: how to dynamically an image source file? justaguy <lichunshen84@gmail.com> - 2015-01-20 12:20 -0800
          Re: quick question: how to dynamically an image source file? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-01-20 14:06 +0100
            Re: quick question: how to dynamically an image source file? Tim Streater <timstreater@greenbee.net> - 2015-01-20 14:52 +0000
              Re: quick question: how to dynamically an image source file? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-01-20 20:47 +0100
        Re: quick question: how to dynamically an image source file? Denis McMahon <denismfmcmahon@gmail.com> - 2015-01-19 21:15 +0000
          Re: quick question: how to dynamically an image source file? justaguy <lichunshen84@gmail.com> - 2015-01-19 14:25 -0800

csiph-web