« first day (95 days earlier)      last day (4855 days later) » 

12:21 AM
@IvoWetzel are you there and awake?
 
@Nathan I was planning on going to bed now :P
 
doesn't this `var` make `i` scoped to the `for` block?: ` for (var i=0; i<lines.length; i++) {
`
 
Already got distracted form that plan though...
 
sorry to disturb your bedtime
 
@Nathan There is no block scope
 
12:22 AM
fails at markdown
 
only function scope
var i will defined i inside the next outer function block
 
so putting var inside your for() is nothing but a false sense of security?
 
No, it is real security.
If you leave it out, you will make it global
 
but if you have multiple for (var i...) loops in your function they're all using the same i?
 
Yes
 
12:23 AM
see, that is counterintuitive coming from other lanugages.
 
Well, learn JavaScript :P
;)
 
trying
 
Read the garden?
While I have no note about the specific case you've mentioned, the lack of block scope gets explained there
 
yes, I've been reading and rereading the garden; that's why I had the question
 
I'll add an example in the scope sections
 
12:27 AM
ahah, reading the doc closely yields "This expression may optionally declare new variables with the var keyword. These variables are not local to the loop, i.e. they are in the same scope the for loop is in." (emphasis mine)
so didn't you recommend one var statement at the top of the function to remind yourself what's really going on? Or did I see that elsewhere...
 
no I don't recommend that
In fact
people who don't know of the lack of block scope might think that's a bug
Just like someone coming from JS and starting in C
might not know that there is block scope
There's no reason to clutter code just because people who have no idea about the language might end up reading it
 
(y)
 
That would be like putting a giant label on every button inside a cockpit
Just for the case someone comes along who has no idea on how to fly a plain...
And the movies showed us that that never happens!
People ending up in those scenarios always handle it fine!!!
 
9
Q: One var per function in JavaScript?

objektivsI've been using JSLint to make me feel bad about my JavaScript. It is great, by the way. There is one check that I don't quite understand and I'd like your views, please. From jslint.com: In languages with block scope, it is usually recommended that variables be declared at the site of first us...

 
I don't like the style, I still keep my variables "definition" near to their use
 
12:34 AM
even though they get "hoisted" to the top
 
yes jQuery uses it, Crockford recommends it
but IMO, if you can't wrap your head around it...
 
which? The "one var" style?
 
yes, that one
You can just as well say that the one var statement can introduce bugs
if you have one var
and the var gets used 50 lines below that
 
...and is mispeled the second time :)
 
what if you forget / remove that var at the top?
now you have a global variable...
 
12:36 AM
right. I am usually a fan of "declare variables close to their first use" theory
along with the "don't declare vars at higher scope than necessary" which I have to plan differently now
 
If you have bugs because you didn't move your vars to the top...
uh... then you don't have decent tests
and if you don't have decent tests...
you have code that does "something" ;)
 
Thanks for the clarification. I think I can navigate the issue OK now.
 
You're welcome
 
"tests" by hitting f5 in a hacked ie6 embedded in this proprietary vendor app
 
1:01 AM
@IvoWetzel Are you going to nominate yourself for the mod election?
 
@jon3laze Thought about it but then again, it's not like I'd have a real chance anyways
 
@IvoWetzel I'd vote for ya :P
 
1:13 AM
@IvoWetzel Even if you have decent tests, you still have code that does "something" (c.f., "testing can prove the presence of bugs, but never their absence", etc.) — but maybe I'm just bitter working at a 190k test level normally :P
 
@gsnedders That's true, but still just moving variable declarations around won't protect you from bugs
 
Indeed. To go back to the point at hand: I've seen several times where people have accidentally dropped a "," at the end of a line, at which point semi-colon insertions comes in, and the remainder of the meant-to-be-local-variables end up defined on the global object (at least in non-strict, in strict they'd throw ReferenceError).
 
194
Code Review

Proposed Q&A site for feedback on projects you're working on, by sharing your code with fellow programmers and getting extensive feedback/review of best practices, design pattern usage, application UI, security, etc.

Currently in commitment.

Only 6 more!
Gogo :)
 
some things that I'd like
some that I wouldn't
he's talking alot about removing keystrokes...
And I'm not a big fan of implicit returns
 
1:25 AM
Often in ways that'll create a large number of branches in the parser, which I'm not sure I like.
 
Well in short: He's dreaming up the language he'd love
Will that be implement in Browser?
Somewhere before... <del> the release of Duke Nukem Forever</del>, Closures make it into Java?
Probably not
 
Harmony will make it into browsers, in whatever form it takes.
Unless ES4 repeats itself.
 
they missed a their big chance with strict mode...
I don't see them take this one, yet
 
But that should be avoidable by actually keeping implementers on-board and not just going off a where-ever they want, ideally with implementations following the spec as it is written.
It's hard to see how sweeping strict-mode could've been, restrictions effectively meant it could have no new syntax
(By personal opinion is that the aim should be to get ES6 out quickly, and that we could've done without strict mode)
 
Well, the main question is, what about backwards compatibility? Sure you can make it go boom
 
1:29 AM
(That absolutely does not, in any shape or form, represent Opera's position on the matter, nor even that there is consensus on that within Opera)
@IvoWetzel The aim for Harmony is to have it as a versioned version of the language, much like JS 1.8 is in SpiderMonkey.
 
Hm, I still see the problem of adoption
Browser will need to take the lead
That means, get Harmony support of 50%+
 
I'm dubious, but given a shared-object-stack it does at least mean things like JS libraries will work from day one.
Yeah, Harmony has to not go down the ES4 route and keep all browser vendors on board.
This was the entire idea of Harmony after the failure of ES4, but I wouldn't write off it happening again, sadly.
 
IE Team...
Still wonder how they will go about IE10
 
I'm not worried about the IE team, I'm worried about MS management :)
 
Oh yeah forgot about MS management. So I guess we can agree on the fact that Harmony is dead, right? :)
 
1:34 AM
I on the whole think management have changed, and that ever since the start of IE7 (and especially IE8) that they've given the IE team the support they need to move forward.
The IE team is nothing but competent — I have absolutely no doubt in /their/ commitment to standards (and yes, I would say that of those who developed IE6 too).
But that's a dangerous view to have around web developers :)
 
Indeed it is
 
(IE6 was really quite good when it came out in terms of standards support — admittedly it wasn't as good as IE/Mac at the time, which was unquestionably the best — and the IE team had every expectation to ship IE7 within a year or two. Then management killed IE/Mac, then shortly therafter IE/Win. Then time passed, and things progressed, then it wasn't so good any more…)
Anyhow, time for me to continue to evade sleep by watching Inception.
 
I should go to bed too...
or I reschedule my visit to the doctor tomorrow monring (in 7 hours)
probably gonna do that, it's not really important
and I have to print out my guide and read through it
and do some other notes...
Reading through 30 pages will be fun
yeah, out of ink -.-
 
1:52 AM
:D
 
Yet again, real world stuff fails
And I'm not going to sell my soul just for a cartridge of printer ink
 
]yes you will
 
Never!
Anyways, gonna go to bed now, still need to wake up at 9am to reschedule the doctor thingy
See you tomorrow morning (maybe even on Code Review.se then)
 
@gsnedders Blasphemy! IE6 was never good at anything except forcing bastardized design.
 
@ircmaxell Still a great Browser to download FX... :P
 
1:55 AM
 
anyways off to bed, good <insert random here>
 
Sure, it may have better supported standards than prior versions, but don't forget a poor implementation of a standard is worse than no implementation...
Laterz
 
 
3 hours later…
4:42 AM
@ircmaxell Compared with the competition at the time, it was good. I'd much rather have a slightly broken implementation than something like Netscape 6/Mozilla 0.9 which simply didn't work for large parts of the web.
(And, as has been said by several on the IE team at the time, had they known there was going to be no further release for five years, more bugs would've probably been considered release-critical, but with the expectation that they'd have another release in around a year, the line was drawn where it was.)
 
sure... likely story ;-p
 
 
4 hours later…
8:41 AM
hi.
 
Hi!
 
Neo
hi
does jQuery(function(){foo();}); only execute on DOM ready only or would it work if it was loaded in page with AJAX?
 
9:50 AM
@Neo it executes on dom ready. Any calls to $(obj).ready after the DOM ready are fired immediatly
 
Neo
I just used a lot of if (window.function_name) and (typeof=='undefined') and fixed the problem
 
function Constructor(arg) {
     var fakeprivate1;
     var fakeprivate2;

     this.foo = function() { ... }
     this.bar = function() { ... }

     // body of the constructor with local variables
     var local = arg.foo
     while (local.next) {
           var thing = local.nextThing();
           constructme(thing);
     }
}
Is there any kind of rule of thumb distinction between fake privates using closures and local variables used for computation inside the constructor?
 
Tek
morning
 
Neo
morning
 
Tek
I know it's not the right room but no one else seems to be online in the chats. Anyone care to help me with a sql query?
 
Neo
10:03 AM
what is it?
 
Tek
I have the following query:

Insert Table2( Column1 )
Select Column1
From Table1 As T1
Where Not Exists (
Select 1
From Table2 As T2
Where T2.Column1 = T1.Column1
)
 
Neo
depends on what type of query
 
Tek
I want to do something like table2 ( column1, column 2)
but I'm not sure where to put column 2's value
 
High Tech
 
Tek
hi :D
 
Neo
10:07 AM
Im not sure what you are trying to do...can you explain it
your query has a shit load of errors right now
 
Tek
no, it works fine
but with one column
 
Neo
INSERT INTO Table2 (column1) VALUES( SELECT Column1 FROM Table1 AS T1 ...?
 
no
 
Neo
Ok yeah I guess it understands that ok I see
 
@Tek personally I would say "go to the sql room and help him"
 
10:09 AM
When you got a Select you don't use Values in Oracle (if that is) if I remember well
 
Neo
you mean @neo
 
Tek
@Raynos I don't seem to be interrupting any javascript conversation, so I don't seem for it to be necessary at the moment?
 
Neo
I'm not getting help./// but I don't think I'm the person to help him
 
Tek
@Raynos only if you insist, I don't want to upset anyone
 
Neo
@Raynos I get my sql help from you
 
Tek
10:10 AM
@ClemDesm Mysql
 
@Tek but the ordered structure of the rooms :(
 
Tek
The rooms don't mind :p
 
Neo
ok you guys need to create a room for room structure for your argument right now
or maybe you should go to chat.meta.SO
 
@Neo thats taking the thing to far
 
Neo
lol :D
 
Tek
10:14 AM
lmao
 
@Tek describe what you want to do. and ill see if I can write something in mySQL
 
Tek
0
Q: Inserting data from one column from one table to another specific table column while ignoring duplicates.

TekI want to insert column1 from table1 to column1 in table2. If the value at column1 in table2 already exists I don't want it to insert it. Though, I found a question on here that is similar but with all the table columns/rows instead of just one, plus both tables have different schemas except for...

Except one more extra set of data came up
and... I can't figure it out lol
how to insert that extra piece in another column with the same query
actually, I think I get it, it might not be possible
 
Neo
how many rows are we talking about?
 
Tek
2
I'm getting the 2nd row from a form variable
 
Neo
I think you should run two queries and use an if statement in your programing for each column
 
Tek
10:18 AM
so I don't need to copy the 2nd row like I did with the first one
 
According to the manual, Insert Table2( Column1, Column2 ) Select Column1, Column2 From Table1 As T1... should work
You may want to use Select T1.Column1, T1.Column2 From Table1 As T1 if you got an error and if the SGBD find conflicts
 
Tek
Right, but I was wondering if I could insert an extra value manually I don't want to copy the 2nd column to another table like I did with the first one
 
Neo
hold on
 
oh
Insert Table2( Column1, Column2 ) Select Column1, 'extraValue' From Table1 As T1...
it works too
 
Tek
oh? =o
I will try that!
 
10:22 AM
without ' if it's an int etc.
 
Tek
Right, thanks.
 
Neo
yeah that was exactly what I was gonna say :D
 
Tek
I didn't know SELECT worked as a replacement for "value"
at least in those type of queries
but that makes sense in think
 
Well, if you make a SELECT query like this Select 'blabla' From Table1, it'll send you 'blabla' as a result.
 
Neo
SELECT 'TheValuePostedByUser' AS 'columnNameForFormValue' is what you want!
right?
 
Tek
10:28 AM
I'll test it in a bit, I have to leave for a min or two
Had to take care of my cat. Now lets see...
Well, I'm glad I backed away for a bit. I think I'm doing this completely wrong. xD
I mean, the way I'm approaching the problem.
I have int values in table1 , column2 that belong to a name colum1 . I want to show statistics. Should I calculate each time a visit uses the page? Or should I create a table2 and insert the name along with the corresponding total value?
 
10:44 AM
I want @YiJiang as moderator
 
@ClemDesm Not nominating myself here, no
 
>_<
 
Tek
@YiJiang Why not?
 
@Tek Because I.. erhn... don't want to be a mod? What more is there to say?
 
Tek
That's a simple enough answer. No need for more. :)
 
10:50 AM
Then we need @IvoWetzel.
 
11:02 AM
Whats the best way to for loop over an object that acts as an array?
I.e. { "0" : foo, "1": bar, "2": foobaz, ... }
I'm using for (var i = 0; data[i] != null; i++) { ... }
 
Does data[i].length not work
 
@TomGullen No, that would only work if our object-like array actually has that property
@Raynos Use a for in loop, with the usual precautions. Or use a while loop if you want to use that syntax
 
@YiJiang but a for in loop doesnt feel right, I'm supposed to iterate over an array not a collection
 
@Raynos Eh.. it is an object not an array, right? And there's no length property
 
@YiJiang there is no length property but I can still check whether the object terminated. The object is "null terminated" if you will.
A seperate question, how do I avoid checks like:
var foo = getSomething();
// check for both null & undefined
if (foo != null) {
    // do something
}
 
11:18 AM
if(foo) should work fine btw afaik
 
@TomGullen if foo does more then that though
 
I'm not 100% but I thought if(foo) checked if foo was not null
 
@TomGullen jsfiddle.net/Raynos/pZ85c if(foo) will also remove 0, "" and false
 
What browser doesn't understand max-width ?
 
Neo
ie
 
11:24 AM
@ClemDesm if its broke. its broke in ie
 
In IE8 it works
I wonder for IE6-7
 
Neo
but ie has a hack for it where you can say expression(javacript goes here)
so you can actually write javascript in your css to resolve the issue but creates a buunch of other security issues
 
ie6 doesn't understand max-*, but ie7 can be "fixed" with javascript hacks to understand more css2.1
 
Alright.
 
Neo
like : width:expression(document.body.clientWidth<501?"500px":"auto");
 
11:26 AM
@Neo you can write javascript inside css?
 
@Raynos A while loop will work just fine, though I still think a for in loop should be best. If you want a for loop, the while loop syntax is cleaner than using a for loop
 
Neo
@Greg yes in ie
here is an example:
 
Since I don't want to put js hacks in my code, my new blog will break on IE6 & 7. Pfff who cares.
 
Neo
#header {
width:expression(document.body.clientWidth<501?"500px":"auto");
}
 
ah, an IE only thing
 
Neo
11:27 AM
yeah
 
@Neo That looks like a min-*.
 
@ClemDesm what's your blog about?
 
@Greg CSS expression is pretty horrible in most cases... but as a workaround here it would work I suppose
 
@Greg PHP/JS/ development in general. I already had one on design.
 
@YiJiang I don't want to have nasty JS to make old broken browsers work.
 
Neo
11:28 AM
yeah you want maxx?
 
@ClemDesm It doesn't look like many readers of your blog would be using IE6/7
 
@Greg CSS expression is JavaScript
 
@Greg Yeah and finally I don't care.
 
Neo
width:expression(document.body.clientWidth>499?"auto":500);
 
@Neo @Greg if you use expression I will come over there and punch you in the face.
 
Neo
11:36 AM
:))
 
@Raynos I will not touch it
I had just never heard of it. But as it's IE only thing, that'd be why.
 
Neo
I don't use expression. I wish there were more websites allowing users to write costum css for their profiles
put some fun XSS
jk
you could allways put something like
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="ie_fix.css">
<![endif]-->
after all I think ie is still the most popular
isnt it?
I hate ie
fuck dont even start me on this
I think microsoft should be sued for ie
 
@Neo they were. They lost a lot of money
 
Neo
lol
who sue them?
 
The fair trade people
You should use google
function (param) {
     // explicity check for boolean true
     // is this bad?
     if (param === true) {
           // do stuff
     }
}
 
Neo
11:56 AM
lol
 
0
Q: Is checking for true explicity bad by design?

RaynosIs it considered bad to explicitly check for the boolean true. Would it be better to do a simple if(success) ? I've seen various jokes made about how if (someBoolean == true) is horrible code in a strongly typed language but is it also considered bad in weakly typed languages? This would apply ...

 
12:14 PM
0
Q: object oriented JavaScript

Web DeveloperIs there any error in my code esp var newpoint[0] = new Point; . I wnat to know on how to do oop in javascript function Point() { var x; var y; } var length = 1; var arrayindex; var newpoint[0] = new Point; newpoint[0].x = 10; newpoint[0].y = 10; for(i=0 ; i<10; i ++) { newpoi...

without words
 

Testing testing 1... 2... 3...

39 mins ago, 34 minutes total – 88 messages, 5 users, 5 stars

Bookmarked 30 secs ago by Yi Jiang

^ You guys totally missed this :P
 
0
A: object oriented JavaScript

Ivo WetzelBefore I comment your code, read a Tutorial: https://developer.mozilla.org/en/JavaScript/Guide And now for entertaiment: function Point() { var x; // great a local variable! var y; // another one! they drop out of scope... (protip: use 'this') } var length = 1; // ??? var arrayindex; /...

 
@IvoWetzel That's cruel. Funny, but cruel.
 
The OP is stupid, funny but stupid
If you don't show any effort
Don't expect any good answers
 
@IvoWetzel Seriously, though - OOP is different in JavaScript compared to other languages - it's not easy groking it
 
12:27 PM
C is different from BASIC
does that mean I can post a question about C with BASIC syntax :P
 
@IvoWetzel But the C-like syntax... it's easy to fall into the trap
 
RTFM
 
@TomGullen what do you mean ambiquity?
 
> gr8 info thanks – Web Developer
hm
 
Well doesn't saying if(var==true) mean that var could be some sort of ambiguous type? Should we not handle our data a bit more strictly? (I dont know, this is just my thought I might be wrong)
 
12:33 PM
@TomGullen you make the mistake into think I'm using type coercion. I use ===
" if (someBoolean == true) is horrible code in a strongly typed language. " That's supposed to be a snippet of <insert strongly typed language> not javascript.
=== is an invalid operator in most strongly typed languages (i.e. C, Java)
Admittedly I didn't make it very clear. I meant the == strong equivelance used in most strong languages which is equivelant to javascript's ===
 
Ah whoops missed that
 
I have a little sanity check button on my page whilst debugging. It either alerts sane or insane. I gain great satisfaction when it tells me I'm sane (It asserts the code has done what it was intended to do)
 

« first day (95 days earlier)      last day (4855 days later) »