Re: SIMPLE Javascript Calculator
JRS: In article <e8vlro$n05$1$8 302bc10@news.de mon.co.uk>, dated Tue, 11
Jul 2006 09:00:55 remote, seen in news:comp.lang. javascript, Richard
Cornford <Richard@litote s.demon.co.ukpo sted :
That supports the principle that every identifier used within a function
should be declared as a var within that function, or passed in as an
argument, except where it is necessary not to do so.
Also the principle that programmer-introduced identifiers should never
be correctly-spelt (or US-spelt) words - Lee's code works for me when
"item" is changed to "iteem".
Javascript needs an equivalent of VBScript's "Option Explicit".
--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.c om/faq/>? JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
JRS: In article <e8vlro$n05$1$8 302bc10@news.de mon.co.uk>, dated Tue, 11
Jul 2006 09:00:55 remote, seen in news:comp.lang. javascript, Richard
Cornford <Richard@litote s.demon.co.ukpo sted :
>Dr John Stockton wrote:
><snip>
><snip>
>
>Because IE browsers use the window/global object to implement the -
>frames - collection the window/global object has an - item - method.
>Without declaring - item - as a global variable the Identifier will be
>scope resolved as that - item - method of the global/window object and
>as a host provided method it is allowed to be read only, so assignments
>to - item - may (and clearly do) error.
><snip>
>Lee's code does not work for me - button gives "Object
>doesn't support this action", line 14 char 5. I don't
>see why - the line is
> for (item in price) {
>But for (var item in price) { works.
>doesn't support this action", line 14 char 5. I don't
>see why - the line is
> for (item in price) {
>But for (var item in price) { works.
>
>Because IE browsers use the window/global object to implement the -
>frames - collection the window/global object has an - item - method.
>Without declaring - item - as a global variable the Identifier will be
>scope resolved as that - item - method of the global/window object and
>as a host provided method it is allowed to be read only, so assignments
>to - item - may (and clearly do) error.
That supports the principle that every identifier used within a function
should be declared as a var within that function, or passed in as an
argument, except where it is necessary not to do so.
Also the principle that programmer-introduced identifiers should never
be correctly-spelt (or US-spelt) words - Lee's code works for me when
"item" is changed to "iteem".
Javascript needs an equivalent of VBScript's "Option Explicit".
--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.c om/faq/>? JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Comment