last day (14 days later) » 

3:42 AM
it's late so we might not get through this. I don't want anything in return.
how about we start with you asking me your doubts about each point
 
I'm perfectly fine picking up later if you're willing
 
yea np
 
when to use for...in? I always use them for arrays with named values (if that's what you call them)
 
hash maps, key value stores, etc.
for in is used exactly for that
 
I suppose the biggest difference is that it loops through all elements, meaning the behavior cannot be changed?
 
3:45 AM
what do you mean by "behavior cannot be changed"?
 
ummm
> Because the for in loop enumerates all the properties that are on the prototype chain and because the only way to exclude those properties is to use hasOwnProperty, it is already up to twenty times slower than a normal for loop.
 
!!> var a = { foo: 1 }; for( var key in a ) { console.log( key ); }
dammit
 
@rlemon SyntaxError: function statement requires a name
 
??
well that is strange
but run it in the console
now, it is safe to use hasOwnProperty for other reasons
 
> avoiding the parseInt octal trap
what does that mean?
 
3:51 AM
always define a radix
!!> parseInt('08');
 
@rlemon SyntaxError: function statement requires a name
 
ugh
 
:googles radix:
 
tl;dr parseInt's second optional argument is the radix.
some browsers default to octal
always supply a radix (10, dec) when using it
 
meaning parseInt('08', 8)?
 
3:54 AM
yes
most browsers default to dec, but you can't rely on it
so why bother
 
if we know the value then what's the point in doing parseInt? XD
 
you can use Number
 
or is dec a keyword?
 
!!> Number('08')
 
@rlemon SyntaxError: function statement requires a name
 
3:55 AM
ugh
I need to stop trying
no dec isn't a keyword
 
didn't think so...
weird
 
dec === 10
 
parseInt('08', 0) works too...
 
decimal
0 is an invalid value so it defaults back to 10
*in modern browsers
 
I see
cool, thanks
 
3:58 AM
again, in modern browsers, Number(string) works in most cases
 
34
A: Referencing a JavaScript value before it is declared - can someone explain this

CMSFunction declarations are subject of hoisting, and they are evaluated at parse time, by hoisting means that they are available to the entire scope in where they were declared, for example: foo(); // alerts foo foo = function () { alert('bar')}; function foo () { alert('foo');} foo(); // alerts b...

I don't even
 
ok well it is just hoisting
var i;
i = foo();
function foo() { return 1; }
consider this
the compiler sees it and turns it into this:
function foo() { return 1; }
var i;
i = foo();
essentially
so it hoists functions to the top of the block
 
so declaring it to a var prevents that
 
yes
 
any use case?
doesn't have to be a code block
 
4:01 AM
clever code
which just ends up being unmaintainable
*top of the current scope
I suck with proper terms.
self taught
 
I understand what you mean
@joshhunt
 
okay well it is midnight here. we can continue this later. sorry
have a good night.
 
you too!
 
!!afk zzZZzzzZzzZzZzZzZz
 

last day (14 days later) »