« first day (3836 days earlier)      last day (1095 days later) » 
00:00 - 22:0022:00 - 00:00

DGF
12:05 AM
Hey guys. I'm doing a simple acessibility website (for people with problems) and I'm trying to add this feature that I saw in code.io: https://codepen.io/robgolbeck/pen/yePRwa (user able to change font-size).
But for some reason it's not working. Here are the gists of html (https://gist.github.com/Head0nF1re/67e90b35359608b99bcabf40528d74cc) and js (https://gist.github.com/Head0nF1re/a1a8cef3e006d02a281b239828a2e981).
If anyone could please take a look and say if it spots something wrong, I would appreciate
 
12:34 AM
Namely this part
function result2Table(result) {
  const rows = tags2rows(result.firstChild.children);

  const table = $("<table/>")
    .attr("id", "resultTable")
    .append(makeHeader(hardCodedListOfHeaders))
    .append(rows);

  return table;
}
This runs every second
 
 
2 hours later…
2:28 AM
 
 
12 hours later…
FZs
2:39 PM
Hi! I've just noticed that "Optional type annotations and static typing, probably using a structural type system" is present on the list of ES6 features in the description of the tag. What is it supposed to mean? I think I know JS well enough to tell that optional type annotations and static typing is not a part of it...
 
@FZs Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
 
 
2 hours later…
4:33 PM
@KevinB Here's an example of what I was talking about github.com/mscdex/socksv5/blob/master/lib/server.parser.js#L41. Notice how they have to use while loop with a switch statement. This is extremely confusing and hard to follow.
Luckily socks5 has few "branches" so for the most part each "step" lines up with each case but for more complicated protocols, it becomes very difficult to follow
 
 
1 hour later…
5:40 PM
the heck?
(It's an array)
oh, nvm... IDK how that happened XD
I just didn't think it is possible
```JS
const array = [];
array[-1] = "foo";
```
IG it is
Oh, multiline doesn't work here, darn
array["foo"] = "bar";
works, too.
Does that have to do with the arrays' prototypes?
 
FZs
No, it's just the fact that arrays are regular objects with some extras (awesome prototype methods, index counting (i.e. length)). But you can do anything with them that you could do with regular objects...
 
Cool... but also annoying xd
JavaScript, let arrays be arrays and objects be objects >:(
Especially annoying with debugging.

People say PHP sucks and now look at JavaScript :/
 
FZs
"arrays be arrays and objects be objects" - they are. If you don't do weird things to them, they'll be OK
 
5:57 PM
True. It just seems harder to debug though.

IDK what went wrong in my code, and I don't want to look through 2000+ lines to fix it (even if I *do* narrow it down I have to scroll up and down and such as the two possible problems are as far apart from each other as east is to west).
It would be easier if it just gave me a type error
Fixed, but I want to know why that happened. I think I could logically just think about what was going on because the program is still somewhat fresh in my mind, but like I said - it would be nicer if it gave me a type error
 
FZs
Sure... but still better than C's undefined behaviour. Btw, your code probably has some indexing problem (e.g. a loop iterating too far, etc.).
 
MHM, that's what I thought. I was making my own language and adding in escaping of things. It gave me `undefined\ee`. Weird.

Also, how do you edit posts?
*dialogues

on chat
 
FZs
Hit the up arrow (key) to edit the last one
 
Huh, it didn't show the first time I tried that. I think I clicked the wrong post. Thanks
Yeah, C's undefined behaviour is fun to work with but if I ever use C in the long run it will probably be a nuisance
 
FZs
@Reality Btw, that'd be a RangeError (not TypeError), yep, there is such thing in JS! (it can be helpful to understand the error kinds)
 
6:07 PM
Yeah, IK about the range error. It rarely happens to me though. What would it be used for again?
I mean, out of range, but what's an example
Oh, new Array(1e+10) gives a range error, ofc.
 
FZs
Also
||> 'a'.repeat(2**53)
 
@FZs "RangeError: Invalid string length" Logged: `` Took: 33ms
 
Wait, u can execute JavaScript?
 
FZs
||> console.log('yes!')
 
@FZs undefined Logged: "yes!" Took: 1ms
 
6:13 PM
How though?
Oh, makes sense. I thought the ||> was JS, but I took a closer look xd
||> console.log("nice")
 
@Reality undefined Logged: "nice" Took: 0ms
 
FZs
|| help
 
Command documentation and syntax can be found here.
 
6:29 PM
Hi so I used geolocation to find a user address and then I compared it against a csv list of places that I parsed using papaparse into an array of json objects and then I used osrm to find the distance.
 
@Jimmy Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
 
but now I want to add a key/value pair to that json object with the distance but i can't seem to access it
can someone help?
 
How is it not accessible?
What does it say?
 
should i link you my so post?
 
sure
 
6:30 PM
1
Q: Why can't I access variable inside a nested function?

JimmySo I have been using the geolocation to find the user location and then find the distance to it and a csv list of locations. I want to save the distance to the json object, but can't access it in my nested function. function onLocationFound(e) { console.log(e); L.marker([e.latitude, e.lon...

 
I haven't tried geolocation yet, tho
 
nah its not that
 
k
 
just within the callback function I cant seem to edit the row object with my new found distance
 
Try logging the row before and after
to see what row is
 
6:35 PM
it an asynchronus function tho
so it gets deported to the end
and I'm not sure how I would log after it
 
Just try it
Maybe
it might work
 
i log it in the callback function
but I dont get it
i get a new one
{Name: null, distance: 265184.8}
 
Log it right before you change it.
 
k
 
If it's the same, then we know it's not row.distance = distance
 
6:37 PM
yeah
its still null
oh wait
lemme
 
Ok, keep logging it until you narrow it down to the thing that is changing it
 
      console.log(row)
      myRoute.route([self_loc, site_loc], function(err, routes) {
          console.log('routing distance: ' + distance);
          row.distance = distance
          console.log(row)
      });
ok so right here
it logs row perfectly fine
 
That's where it's null
 
and then in the function it becomes the null thing
 
That is interesting
 
6:39 PM
its not able to access row or something
 
It should be
 
its an async callback function
so myRoute.route is a request aganist my osrm backend
and then function is my callback function
 
myRoute.route is async
?
 
ye
 
k
 
6:40 PM
so it does everything
then it does the request
I'm assuming its some kind of scope problem
 
is row morphed anywhere else?
 
no
i just iterate through the array
and row is the object
 
IDK then, it is weird
Usually scope isn't a problem like that in JS
 
i might try async or something
but im a bit of a noob at js and don't really know how
 
the function you use await in has to be async
 
6:43 PM
hmm
 
async function(){await promiseStuff();}
 
but shouldnt the function just be able to access row
thats what im confused about
 
mhm
try an arrow function instead
change function(err, routes){}
 
whats that
 
to (err, routes)=>{}
it doesn't have scope
it inherits the scope of what it's in
 
6:44 PM
alright ill try
 
if that works, then we know it's a scope problem (probably)
otherwise, IDK
 
when i try that
i get routing distance: undefined
 
is it supposed to be err, routes
or routes, err
 
i think err, routes
the documentation isn't very clear
 
k. Why is distance defined outside of the block?
 
6:46 PM
wdym
 
var distance; isn't inside of the callback
 
oh
that was a goof
 
It doesn't need to be there
 
i tried fixing it on my own before so and must've forgot to delete something
 
k
var row
hm
 
6:48 PM
yeah
thats the one i wanna change
but instead its making a new one
 
yeah, hang on... there might be something but IDK if it is true or not
 
aight thanks
 
yeah, it isn't that
try changing var row to let row instead
 
oh
IT WORks
you are a godsend
 
yeah
 
6:50 PM
thank you so much bro
 
ok so here's the prob
can I put it as an answer/
?
 
yeah of course
 
kk
ok
I linked my suspicions, hope I don't get downvote spammed xd
 
thanks bro
pretty new to so and just js in general
 
mhm
np. You totally didn't spend my time making a tutorial on my own language.

Jk, it was worth the waste to help a fellow programmer :-)
 
6:56 PM
ohhh mb bro
thank you so much
 
Nah, it's fine. Like I said, I'm more inclined to help someone then to spend time on my own things.

I'm just glad to see you happy.

Np :)
 
i dived head first into making a website to help people find their nearest vaccination site in my home state with basically a small ounce of web development experience
and boy has it bean a wild ride
 
mhm
 
ill let you work now, and thanks again
 
That's me with questions - thus getting me question banned.

My advice?

I def recommend you take time and fiddle around with it first before posting a question.
I'm in this room until ~5 CST (I may leave sooner tho) to attempt to help
 
6:59 PM
alright bro
if I need anything I know where to look
 
7:27 PM
hey bro could you explain the difference between let var and const?
 
const means that the variable can't be changed
note that arrays can be mutated, as well as objects
372
Q: Const in JavaScript: when to use it and is it necessary?

axdgI've recently come across the const keyword in JavaScript. From what I can tell, it is used to create immutable variables, and I've tested to ensure that it cannot be redefined (in Node.js): const x = 'const'; const x = 'not-const'; // Will give an error: 'constant 'x' has already been defined' ...

 
7:39 PM
should I ever use var?
 
not rlly
if you know JS well enough, it shouldn't come up as a question, even
 
I don't
so always use const or let?
 
pretty much
It's by choise
*choice
but it's a good practice to not use var
or, at least, programmers say you shouldn't use it
 
8:29 PM
if i use let just like not in a block
does that make it global?
 
it attaches it to the scope
maybe not global, but in whatever function
btw arrow functions have no scope, so they "inherit" the scope of what they are declared in, basically
 
so
ex i have code
let x =5;
just out in the wild not in a function
can i use that x anywhere?
 
what other languages r u familiar with?
(for examples)
 
python
 
ok
 
8:35 PM
python 3
which is why im semi confused
 
if you define a variable inside of a function
can you use it outside of that function?
 
no
local scope
 
mhm
same with let
however, JS allows code blocks ({})
 
or actually
i forgot but technically yes you can use a global keyword to create a global variable
just its considered bad practice
 
||> {var foo = "bar"};console.log(foo);
huh, ok nvm
usually the bot should show up
||> console.log(foo);
 
8:37 PM
@Reality "ReferenceError: foo is not defined" Logged: `` Took: 0ms
 
||> {var foo = "bar"};console.log(foo);
 
@Reality undefined Logged: "bar" Took: 0ms
 
see @jimmy?
||> {let foo = "bar"};console.log(foo);
 
@Reality "ReferenceError: foo is not defined" Logged: `` Took: 1ms
 
see the difference @Jimmy
{} can be used for objects, function blocks, OR code blocks
 
8:39 PM
ohh
 
let can be used only inside of all of them, while var can work outside of code blocks
but not outside of the current scope of that code block
 
hmm
lemme try a test
so objects would be like
var x = {y:4, z:2}
right?
 
it depends on the context
mhm
 
and then function would be
 
if you do code blocks after function e(), then JS knows its a function
 
8:41 PM
function myfunction {}
 
if you do it without anything, like this: {console.log("foo")}, then JS knows it is a code block
It depends on context
where the {} are placed
 
whats the difference between a code and function block?
 
code block is like an anonymous function, kinda
or, sorry... an IIFE
except you don't pass stuff into it
A code block allows you to just put stuff in that scope of the code block.
 
could you give an example of a function and a code block and their differences?
 
{/*stuff here without letting the outer scope know... unless you use var and such*/}
 
8:45 PM
so that would tie everything there to that code block right?
 
@Reality w3schools is a terrible resource. We suggest using MDN. Here's an potentially equivalent page: Statements and declarations - JavaScript | MDN
 
might explain code blocks
xd, jamesbot no it aint...
 
ah ok
thanks
 
but yeah, anyways...

Basically, @Jimmy code blocks are used to tie stuff together, yes.

Functions are code blocks that can be run again and again, with stuff passed in
 
8:46 PM
ye
just wanna crawl back into my familar python
 
xd, yeah. I don't like python, but probably just because everyone else is using it. I use Go instead
 
python's pretty readable
and with libraries its basically endless
 
yeah
slow tho
 
yeah
and libraries can be limited
 
anyways..
 
8:53 PM
originally I was using folium which uses leaflet.js
but some functions and plugins weren't ported
and so here I am writing js
 
oof
JS is weird.
arrays can be store keys, as I found out
||> (new Array(0))[-1] = "foo"
 
@Reality "foo" Logged: `` Took: 0ms
 
||> console.log((new Array(0))[-1] = "foo");
 
@Reality undefined Logged: "foo" Took: 0ms
 
ok, nvm it doesn't look good with jamesbot, but arrays can have a -1 index
which, is weird and somewhat unhelpful at times
 
8:56 PM
is there a difference between node js and just js on the web?
 
nodejs and js have the same syntax
but different stuff
well, some things are the same
 
9:51 PM
@Reality but it is :)
 
How so?
 
w3schools also has generally less detailed, less accurate, and usually out of date information
 
true
It's good for noobs, though
 
it is not
 
It depends
but IG
 
9:53 PM
It teaches bad practices and bad habits which cause problems
 
Never seen it, but then again I've never cared to look
 
As suggested by James, MDN is preferred
 
Yeah. Unfortunate that my school does not seem to like MDN
 
Your school suggests w3schools?
 
Nope
Blocked
 
9:55 PM
MDN is blocked?
 
I am one of those people who have minimal access to most resources on the internet. Somehow I have become the programmer I am today
 
You should request that your school unblocks MDN as it's an invaluable educational resource
 
mhm
I can assume they don't want us downloading firefox, but ironically we use chromebooks with chrome OS, which can't download firefox unless you switch channels, which is restricted as well
 
00:00 - 22:0022:00 - 00:00

« first day (3836 days earlier)      last day (1095 days later) »