« first day (2853 days earlier)      last day (2320 days later) » 

19:00
So the first log we get is 1
@KevinB when did the whole thing get set to the fileName... that is what I am confused with
@ChristianMatthew but it doesn't have a fileName property
I got tired of your 3 words per line and ran it
@rlemon what code do you want? Its in not in a single file.
foo[fileName] doesn't create a fileName property.
19:00
Now though, the fun part: The copy and increment happens before the iteration for every iteration except the first
user1596138
@MadaraUchiha Why does this already disagree with what Chrome just did
@JBis the output. the page is rendered as a single HTML file
no but it references one doesn't it
user1596138
@MadaraUchiha The first log is 0.
maybe with some JS files and CSS files.
19:00
@LadyBird Because you didn't count the fact that a for loop has a return value :D
but the HTML is one file
it refrences fileName
@ChristianMatthew No, it simply creates a property that is named whatever is in fileName
@MadaraUchiha I'm not getting 1
first
it's not in any way a reference
19:01
@rlemon ok. can I at least strip away some info.
it's simply a string
@rlemon Try this if you're running in the console:
for (let i = 0; i < 2; i++) {
  setTimeout(() => console.log(i));
  i++;
}
'foo'
user1596138
!!> for (let i = 0; i < 2; i++) {setTimeout(() => console.log(i));i++;}
@LadyBird "undefined" Logged: 1
That works
19:01
foo[fileName] is the same as saying foo.fileName and is an object named foo = {fileName: 'somefilename'}
am I wrong about that?
Yea, you're wrong on that
user1596138
user1596138
No sir.
user1596138
It logs 0, 1
So what happens here? The copy and increment happens before the second iteration, for every iteration except the first, the incrementor runs before
19:02
my mind is blown?
user1596138
What the fuck is happening lol
this makes no sense to me why putting a random string after the loop negates the first return?
yea, that's fucky
foo["fileName"] is the same as foo.fileName. The quotes are important. Without the quotes, it will evaluate fileName and use the result of that as the key name.
So you get 0 (increased to 1) then before the second iteration starts, i is increased to 2 and doesn't pass the condition
user1596138
19:02
Ahhhh okay
@rlemon Because a for loop has a value
But that's a story for another day
We had this discussion last week.
the 0 you see is the return value, not a print
but for() returns undefined.
19:03
lol ok sorry
let me rewrite that...
so the console is lying to me? or
foo["fileName"] is the same as saying foo.fileName and is an object named foo = {fileName: 'somefilename'}
is that correct
user1596138
!!> (() => {for (let i = 0; i < 2; i++) {setTimeout(() => console.log(i));i++;}})()
@LadyBird "undefined" Logged: 1
19:03
that is correct
user1596138
Negating the return value... Yeah, it logs 1
I'm willing to accept the console lies to me
user1596138
Should have used console.info to avoid this :P. You set us up it was a trick
but I'd like to see something about for(;;) returning a value
Now the more interesting bit
19:04
ok so what i am saying is... how can this statement... currentDownloadStateArray[fileName] = currDownloadObject; even if it where this to make it simple currentDownloadStateArray["fileName"] = currDownloadObject;
ohhh, it returns the last statement in the body
that's super fucked up
not make that property for fileName turn into this... foo = {fileName: currdownLoadObject}
@ChristianMatthew that's exactly what it does, when you use "fileName"
user1596138
user1596138
I feels tricked, good one
19:05
my out put doesn't show me that
for (
  let i = (setTimeout(() => console.log(i)), 0); // note, using comma operator, not second param
  i < 2;
  i++)
{
  i++;
}
It probably does, just not in the way you were expecting.
seriously, I never knew this behavior before and it's messing with me
here is an exmaple...
19:06
@LadyBird How the numebr became 2862?
https://vse-content.s3.amazonaws.com/vrd/prod/navigation/az.png:
complete: true
completeOrder: 1
currentSize: 7451
fileName: "https://navigation/az.png"
order: 1
totalSize: 7451
Instead of currdownLoadObject, you'll see the object that currdownLoadObject is.
What's getting logged now? :D
filename is now an object only it's filename...
how can I abuse this... :thinking:
19:06
@ChristianMatthew No, fileName contained "https://vse-content.s3.amazonaws.com/vrd/prod/navigation/az.png"
@jake It's not nice to blow the discussion up :(
user1596138
@PukaUnknown Yellow is the console warns, that 2862 is the ID for the settimeout
and now the currentdowloadStateArray is set to fileName
that is incorrect
user1596138
Do console.log(setTimeout(()=>{})), you'l get a ID like that
19:07
@MadaraUchiha ?
that is what my log tells me
yea, the last statement is teh value returned from the for(;;)
that's weird man
@jake Don't reveal the answer if you already know it, let people think
@LadyBird wow
user1596138
Tricky ay?
user1596138
19:07
Sure got me.
https://navigation/az.png:
complete: true
completeOrder: 1
currentSize: 7451
fileName: "https://navigation/az.png"
order: 1
totalSize: 7451
@LadyBird you mean whenever i create a setTimeout, the browser gives an id to it?
Another fun side question, how can I get and use the value of the for loop? @rlemon @LadyBird
this is what currentDownloadStateArray logs out
you're misinterpreting it. fileName contains "https://vse-content.s3.amazonaws.com/vrd/prod/navigation/az.png", therefore foo[fileName] = "Hello World!" will result in {https://vse-content.s3.amazonaws.com/vrd/prod/navigation/az.png: "Hello World!"}
which is exactly what you're seeing
user1596138
19:08
@PukaUnknown Oh for sure! How do you think you cancel a setTimeout? SetInterval has identical behavior
@lady From what value?
@PukaUnknown Correct, that same ID you can pass to clearTimeout() to dismiss it.
@rlemon hopefully I didn't miss anythhing
user1596138
If you wanted to clear the setTImeout you'd need to use clearTimeout on that ID
@LadyBird wow, didn't know that! :)
19:09
@MadaraUchiha arrows?
user1596138
For example... var myTimer = setTimeout(something); clearTimeout(myTimer);
I used to use something like: yea
user1596138
That is the only way to clear it. Same goes for setInterval (with clearInterval)
exactly what u just wrote
But why do we need these id's then?
But try to answer this first one first
3 mins ago, by Madara Uchiha
for (
  let i = (setTimeout(() => console.log(i)), 0); // note, using comma operator, not second param
  i < 2;
  i++)
{
  i++;
}
What's getting logged now?
19:09
@KevinB can you jsbin that
We won't be able to clearTimeout if it's not assigned to the variable\
Or am I wrong?
user1596138
That's right, you don't save it you can't clear it
@PukaUnknown const x = setTimeout(() => doSomething(), 0) what do you think x now holds?
@LadyBird sure you can šŸ˜› more than likely.
user1596138
@MadaraUchiha Now I fully understand,.
user1596138
19:10
It is 0.
while( i < 9e99 ) clearTimeout(i++);
copy and paste
clearTimeout(Math.round(Math.random() * Number.MAX_SAFE_INTEGER)); // thoughts and prayers
@MadaraUchiha the doSomething function?
@MadaraUchiha Im quite confused :df
@PukaUnknown No, setTimeout returns an ID, a number
19:11
const foo = {};
const fileName = "https://vse-content.s3.amazonaws.com/vrd/prod/navigation/az.png";
const myObject = {"foo": "bar"};
foo[fileName] = myObject;
console.log(foo);
That's what x will have
@MadaraUchiha We both posted within the same minute, I was busy typing that example from the video
@jake Ah, lol, my apologies then. But I was building towards that :D
@MadaraUchiha fun fact (I've told this before) timeout and interval share the same timer pool
the above code is all you're really doing.
19:12
@rlemon So its not apache cause doesn't work with html file
np, its a very interesting video
@MadaraUchiha nice
14531
Can we use this to clear the timeout like clearTimeout(14531)?
The end result should be {https://vse-content.s3.amazonaws.com/vrd/prod/navigation/az.png: { foo: "bar"}}
@MadaraUchiha Now it makes sence
Thanks! :D
@PukaUnknown Correct
So no takers on my question? @rlemon @LadyBird?
user1596138
19:14
I answered you
I can't figure out how to use the return of a for
my best bet was implicit return from an arrow
but that errors
u guys rock! :D gonna do some stuff with laravel tonight
ohhhhhhh maybe in a template literal
nope
@rlemon Simpler solution exists
yea I don't see it
19:16
One that has been a part of the language for ~20 years
Maybe more
eval?
because shame on you
user1596138
Oh I didn't know you asked that
That's actually not the question I asked :D
That was a side question
This is my question
user1596138
19:16
I said second example returns 0
10 mins ago, by Madara Uchiha
for (
  let i = (setTimeout(() => console.log(i)), 0); // note, using comma operator, not second param
  i < 2;
  i++)
{
  i++;
}
user1596138
Because I think I understand what is happening now.
user1596138
Not exactly how it is accomplishing it tho. Waiting on the answer
@rlemon your guess?
user1596138
19:17
.
@MadaraUchiha error?
@rlemon What kind of error ?
user1596138
Like I'm able to predict it now, but I don't know exactly how it is doing this. is it doing let i = i; in the begining of every iteration?
@MadaraUchiha ref
user1596138
My question is how is it actually creating a new lexically scoped var per iteration.
19:18
@KevinB I have this jsbin jsbin.com/hiwomaxaji/edit?html,js,console,output which this part does what i expect.
@LadyBird Yes, you are very close
user1596138
It's not something you have to care about.. But now I want to know
So the correct answer is indeed 0
10 points for Gryffindor @LadyBird
user1596138
Somehow 10 == 0 here tho
user1596138
I am sure
19:19
So actually, what happens is that this first statement has a lexical scope of its own
No, what happens is you fail a code review :p
// So it's akin to
(() => {
  var i;
  i = (setTimeout(() => console.log(i)), 0);
  return i;
})()
user1596138
So since let chains and you could only really make a bunch of lexical vars
user1596138
This works no matter how many things you define and it essentially does let X = oldX on every iteration?
19:21
@rlemon Any ideas?
user1596138
Nice. Not something I'd thought to contemplate
I have to say that this behavior was much more involved and branched than I had imagined.
@JBis the debugger statement will block you. Otherwise no
@ChristianMatthew but you're not using 'fileName' in your code, you are using fileName
user1596138
19:21
So it really is something that happens only for for loops
it's quite different.
user1596138
No comparable behavior would exist anywhere else
@rlemon what?
user1596138
And it's "magic"
user1596138
Is this a specific code path, or is this inherent to using lexical vars in a for and it works just like it did with var
19:22
@rlemon I added that for debugging purposes hence debugger
@Jake u got any ideas?
@JBis I mean, there is nothing standing out that would cause it not to run
the debugger will pause for you, maybe you're not seeing that pause?
...I am seeing the pause
user1596138
Seems to me it probably works exactly the same with var, redefining var i = oldI every iteration, except the scoping is different so you get different results. Or is it truly a "special case" in the spec
but do you see how its not working?
@LadyBird It is (a special case)
19:24
no, I am not running it
I just read the code
try editTVlinks() in consle
well, skimmed it
@rlemon why?
user1596138
@MadaraUchiha Link? Or have you just observed it
Although it would be very interesting to see how Babel/TypeScript generate it
19:25
@JBis because I haven't?
@rlemon cn you plz? so u can see what I mean.
nothing will work if I try
you check against location.href
I don't own your domains
and I'm not changing all of those
hold on ill change
if you have a live page up somewhere, I'll look at that
// TypeScript converts
for (let i = 0; i < 2; i++) {
    setTimeout(() => console.log(i));
    i++;
}

for (let g = (setTimeout(() => console.log(g)), 0); g < 2; g++) {
    g++;
}

// Into
var _loop_1 = function (i) {
    setTimeout(function () { return console.log(i); });
    i++;
    out_i_1 = i;
};
var out_i_1;
for (var i = 0; i < 2; i++) {
    _loop_1(i);
    i = out_i_1;
}
var _loop_2 = function (g) {
    g++;
    out_g_1 = g;
};
var out_g_1;
for (var g = (setTimeout(function () { return console.log(g); }), 0); g < 2; g++) {
user1596138
19:27
Lots of askers getting lots of answers the past 2-3 days. Good work room
user1596138
Or maybe it's just when I'm on. But seems good
@rlemon can't give access to that
ok i think this is a good representation of what i am dealing with...
see how foo is set to a new object the way it is
Are these equal?
$('#id_obj').click(function(event) {
     event.preventDefault(event);
}
$('#id_obj').click(function(e) {
     e.preventDefault(e);
}
(I'm talking about cross browsering)
there is no change
19:30
ok good
user1596138
@ChristianMatthew What's the question? You made foo = {fileName: {}}, cool, but what's wrong?
IF you're concerned about windows, even is overwrote in the function scope
@Shafizadeh Yes, you've simply renamed the function parameter
IE has a global event
@rlemon Ok. Its only one check thats relevant.
19:31
I imagine that is causing someone to second guess it
It's like asking if function foo($a) { return $a; } is equivalent to function foo($b) { return $b; }
You should also know that preventDefault() doesn't accept parameters
Just e.preventDefault() is enough.
user1596138
@ChristianMatthew Did you expect {goodbye world: otherObject}?
user1596138
You hardcoded 'fileName' and never used your variable.
19:32
@MadaraUchiha I see what you say .. but my code uses "e" as that parameter and I seen this and I thought probably I have to use "event" word literally as that parameter
@rlemon I changed the relevant stuff can you run now?
@Shafizadeh That is an answer from 2012
you'd better have that e-beer account already open šŸ˜‰
:-) ..! the browser my website users use is for that time either :-(
user1596138
@ChristianMatthew What you log foo[fileName] = {} is false, it is foo['fileName'] = {}
19:33
@Shafizadeh Firefox auto-updates though
The code does exactly as i would have expected it to.
user1596138
Also all of those can be const, nothing is mutated at all
@rlemon fyi just changed something
no this is my output...
"foo "
[object Object] {
  fileName: [object Object] {
    andAnother: "thing",
    fileName: "goodbye world",
    something: "else"
  }
}
"foo[fileName] = "
[object Object] {
  andAnother: "thing",
  fileName: "goodbye world",
  something: "else"
}
@JBis lol ` if (1=1) {`
yea that's not going to work
19:36
@rlemon yep thats what I fixed. realized right after I posted.
ok so @KevinB my question is the same... why does foo turn into the object it does... which is this
user1596138
Oh I misread haha
user1596138
!!afk I dumb
{
  fileName: [object Object] {
    andAnother: "thing",
    fileName: "goodbye world",
    something: "else"
  }
}
@rlemon reload link
plz
19:36
lady
:)
@LadyBird i dont' get what you are saying
@MadaraUchiha That's not true at all, both have their merits in programming (@david surely seems to agree)
        setTimeout(function() {
                editTVlinks();
                getImage();foo

            }, 1000);
you have a random foo there
19:38
@copy Sure but the practical aspect in this case is (probably) that round(int result) + round(modulo result) will equal the numerator
Also you should really set that after you declare the function
@copy so that's partly true
That has lots of subtle "free" functionality you get
@jake js fixes that I thought
19:38
@rlemon I was rushing to fix all sensitve info you can just remove it
yes, but that throws an error
lol, so I'm going to point it out
@JBis Don't rely on JS to eat your vegetables for you.
now, in my link above. what should I be expecting
@MadaraUchiha That also holds for euclidian divison and modulo
@rlemon line 35 change that to 2000. Thats the expected result.
19:41
(with different rounding rules for the division)
@JBis you do know you're running the function more than once in the load right?
i know i am not crazy but i am begging to think that i am... i just dont' get how foo is turned into the object it is turned into... my expectation would be this... foo = {
fileName: otherObject,
}
which is what it is
if( whatever ) {

} else {
  run the link function
}

if( whatever ) {

} else {
  // run the link function again..
}
haaaa hahhaaaa i get it
lmao... i get it now
the object is empty
if you don't call editTVlinnks() again it works
your problem is stacking up those calls
19:43
am i am literally setting and creating an property which is set to an object
I removed the rest of that function
you can see with only one call it works
@rlemon There shouldn't be any others
but there are
It's things like this that make me question if dissuading jQuery use has a negative impact. Everyone wants to be a strong, independent developer who doesn't need jQuery...
only once
19:45
that else will always hit at the end
so when you expect the first one to run, the second will always run
editlinks() different editTVlinks()
they both work on the same table
so
one replaces the others contents
so here is my true question... when an object is empty and you set it to a property it will then create that new object with said property
19:47
if you run them at the same time (current code) you have a race condition for who wins
if you make one longer (1001, or 2000) it over writes the other
but shouldn't scope fix that
how does scope matter?
both end with ` document.getElementById("list").innerHTML = putit;`
you're nuking the old table
oh shit
@ChristianMatthew i don't understand the misunderstanding. :(
it does what it does,
if you set A to 1, A will be 1
anyways, I'd look there. I can't sift through this code any longer
good luck
19:49
@rlemon why cause its so bad? lol. Thanks for your help! I am working on cleaning it up...
@rlemon rlly app ur tm

« first day (2853 days earlier)      last day (2320 days later) »