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


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

object giving errors

Started byAndrew Poulos <ap_prog@hotmail.com>
First post2019-12-12 19:20 +1100
Last post2019-12-14 17:24 +0100
Articles 7 — 4 participants

Back to article view | Back to comp.lang.javascript


Contents

  object giving errors Andrew Poulos <ap_prog@hotmail.com> - 2019-12-12 19:20 +1100
    Re: object giving errors Julio Di Egidio <julio@diegidio.name> - 2019-12-12 00:31 -0800
      Re: object giving errors Andrew Poulos <ap_prog@hotmail.com> - 2019-12-12 20:36 +1100
    Re: object giving errors Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2019-12-12 10:11 +0100
      Re: object giving errors Andrew Poulos <ap_prog@hotmail.com> - 2019-12-12 20:38 +1100
        Re: object giving errors Julio Di Egidio <julio@diegidio.name> - 2019-12-12 02:21 -0800
    Re: object giving errors "R.Wieser" <address@not.available> - 2019-12-14 17:24 +0100

#37953 — object giving errors

FromAndrew Poulos <ap_prog@hotmail.com>
Date2019-12-12 19:20 +1100
Subjectobject giving errors
Message-ID<h5Cdnb0TscbyZWzAnZ2dnUU7-f3NnZ2d@westnet.com.au>
Why is it that when I do this

function pos() {
   return { "top": 10, "left": l20 };
}

or this

function pos() {
   let o = { "top": 10, "left": l20 };
   return o;
}

I get "Uncaught ReferenceError: l20 is not defined".

But when I do it like this

function pos() {
   let o = {};
   o.top = 10;
   o.left = 120;
   return o;
}

I get no errors?

Andrew Poulos

[toc] | [next] | [standalone]


#37954

FromJulio Di Egidio <julio@diegidio.name>
Date2019-12-12 00:31 -0800
Message-ID<6f346103-79d8-44bb-a4a7-28ef1615d784@googlegroups.com>
In reply to#37953
On Thursday, 12 December 2019 09:21:15 UTC+1, Andrew Poulos  wrote:
> Why is it that when I do this
> 
> function pos() {
>    return { "top": 10, "left": l20 };
> }
> 
> or this
> 
> function pos() {
>    let o = { "top": 10, "left": l20 };
>    return o;
> }
> 
> I get "Uncaught ReferenceError: l20 is not defined".
> 
> But when I do it like this
> 
> function pos() {
>    let o = {};
>    o.top = 10;
>    o.left = 120;
>    return o;
> }
> 
> I get no errors?

l20 is just not the same as 120...

Haven't yet had your coffee yet?

Julio

[toc] | [prev] | [next] | [standalone]


#37956

FromAndrew Poulos <ap_prog@hotmail.com>
Date2019-12-12 20:36 +1100
Message-ID<7aidnc1N1teRl2_AnZ2dnUU7-R2dnZ2d@westnet.com.au>
In reply to#37954
On 12/12/2019 7:31 pm, Julio Di Egidio wrote:
> On Thursday, 12 December 2019 09:21:15 UTC+1, Andrew Poulos  wrote:
>> Why is it that when I do this
>>
>> function pos() {
>>     return { "top": 10, "left": l20 };
>> }
>>
>> or this
>>
>> function pos() {
>>     let o = { "top": 10, "left": l20 };
>>     return o;
>> }
>>
>> I get "Uncaught ReferenceError: l20 is not defined".
>>
>> But when I do it like this
>>
>> function pos() {
>>     let o = {};
>>     o.top = 10;
>>     o.left = 120;
>>     return o;
>> }
>>
>> I get no errors?
> 
> l20 is just not the same as 120...
> 
> Haven't yet had your coffee yet?

Oh my, I've been looking at for ages and I couldn't work out what was wrong.

Andrew Poulos

[toc] | [prev] | [next] | [standalone]


#37955

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2019-12-12 10:11 +0100
Message-ID<4494564.GXAFRqVoOG@PointedEars.de>
In reply to#37953
Andrew Poulos wrote:

> Why is it that when I do this
> 
> function pos() {
>    return { "top": 10, "left": l20 };
> }
> 
> or this
> 
> function pos() {
>    let o = { "top": 10, "left": l20 };
>    return o;
> }
> 
> I get "Uncaught ReferenceError: l20 is not defined".
> 
> But when I do it like this
> 
> function pos() {
>    let o = {};
>    o.top = 10;
>    o.left = 120;
>    return o;
> }
> 
> I get no errors?

The first code snippet contains a reference to the variable with identifier 
(in words) “‘U+006C Latin Small Letter L’, followed by ‘U+0032 Digit Two’, 
followed by ‘U+0030 Digit Zero’”; the second one contains the decimal 
numeric literal (in words) “one hundred twenty” (i.e. “U+0031 Digit One”, 
followed by “U+0032 Digit Two”, followed by “U+0030 Digit Zero”).

Using an *unambiguous* *monospace* font like “DejaVu Sans Mono” (free 
software), “Bitstream Vera Mono” (Open Source) or “Consolas” (proprietary; 
de Groot/Microsoft), and an editor supporting code completion, like 
Atom(.io), and a code checker like ESLint(.org), for software development, 
helps to avoid such problems.

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#37957

FromAndrew Poulos <ap_prog@hotmail.com>
Date2019-12-12 20:38 +1100
Message-ID<7aidncxN1tcrl2_AnZ2dnUU7-R0AAAAA@westnet.com.au>
In reply to#37955
On 12/12/2019 8:11 pm, Thomas 'PointedEars' Lahn wrote:
> Andrew Poulos wrote:
> 
>> Why is it that when I do this
>>
>> function pos() {
>>     return { "top": 10, "left": l20 };
>> }
>>
>> or this
>>
>> function pos() {
>>     let o = { "top": 10, "left": l20 };
>>     return o;
>> }
>>
>> I get "Uncaught ReferenceError: l20 is not defined".
>>
>> But when I do it like this
>>
>> function pos() {
>>     let o = {};
>>     o.top = 10;
>>     o.left = 120;
>>     return o;
>> }
>>
>> I get no errors?
> 
> The first code snippet contains a reference to the variable with identifier
> (in words) “‘U+006C Latin Small Letter L’, followed by ‘U+0032 Digit Two’,
> followed by ‘U+0030 Digit Zero’”; the second one contains the decimal
> numeric literal (in words) “one hundred twenty” (i.e. “U+0031 Digit One”,
> followed by “U+0032 Digit Two”, followed by “U+0030 Digit Zero”).
> 
> Using an *unambiguous* *monospace* font like “DejaVu Sans Mono” (free
> software), “Bitstream Vera Mono” (Open Source) or “Consolas” (proprietary;
> de Groot/Microsoft), and an editor supporting code completion, like
> Atom(.io), and a code checker like ESLint(.org), for software development,
> helps to avoid such problems.

You guys saw the issue straight-away but I was stumped. I'll update my 
fonts accordingly.

Andrew Poulos

[toc] | [prev] | [next] | [standalone]


#37958

FromJulio Di Egidio <julio@diegidio.name>
Date2019-12-12 02:21 -0800
Message-ID<cfbb48de-1405-4d66-9d3b-b200f4a3119f@googlegroups.com>
In reply to#37957
On Thursday, 12 December 2019 10:39:12 UTC+1, Andrew Poulos  wrote:
> On 12/12/2019 8:11 pm, Thomas 'PointedEars' Lahn wrote:
> > Andrew Poulos wrote:
> > 
> >> Why is it that when I do this
> >>
> >> function pos() {
> >>     return { "top": 10, "left": l20 };
> >> }
> >>
> >> or this
> >>
> >> function pos() {
> >>     let o = { "top": 10, "left": l20 };
> >>     return o;
> >> }
> >>
> >> I get "Uncaught ReferenceError: l20 is not defined".
> >>
> >> But when I do it like this
> >>
> >> function pos() {
> >>     let o = {};
> >>     o.top = 10;
> >>     o.left = 120;
> >>     return o;
> >> }
> >>
> >> I get no errors?
> > 
> > The first code snippet contains a reference to the variable with identifier
> > (in words) “‘U+006C Latin Small Letter L’, followed by ‘U+0032 Digit Two’,
> > followed by ‘U+0030 Digit Zero’”; the second one contains the decimal
> > numeric literal (in words) “one hundred twenty” (i.e. “U+0031 Digit One”,
> > followed by “U+0032 Digit Two”, followed by “U+0030 Digit Zero”).
> > 
> > Using an *unambiguous* *monospace* font like “DejaVu Sans Mono” (free
> > software), “Bitstream Vera Mono” (Open Source) or “Consolas” (proprietary;
> > de Groot/Microsoft), and an editor supporting code completion, like
> > Atom(.io), and a code checker like ESLint(.org), for software development,
> > helps to avoid such problems.
> 
> You guys saw the issue straight-away but I was stumped. I'll update my 
> fonts accordingly.

I've immediately seen it here on GG where the font is not even monospace:
by looking at the code and the error (ah, the good old days, when we did not
have any of the fancy tools...).  It just can happen, above all if one has
been staring at code for days: indeed, a little bit of experience also helps,
as in been there done that.  But, of course, also the editor helps: to add
to the above, an editor with syntax colouring.

Have fun,

Julio

[toc] | [prev] | [next] | [standalone]


#37959

From"R.Wieser" <address@not.available>
Date2019-12-14 17:24 +0100
Message-ID<qt32ba$189m$1@gioia.aioe.org>
In reply to#37953
Andrew,

> Why is it that when I do this [snip]

I assume you have already found the problem.

But if not /and/ you have actually copy-pasted what you did into your 
message than take a good, hard look at those "l20" that do not work, and 
that "120" that does. They are not the same.

More hints ? Look at the first symbol of each.  Do you see it ?

Regards,
Rudy Wieser

[toc] | [prev] | [standalone]


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


csiph-web