« first day (660 days earlier)      last day (4305 days later) » 

10:00 PM
@Neal I'm definitely not one of the JQ haters, but there is a lot of stuff I tend to side-step/ignore which is relatively easy to do which is one of the things I've always liked a lot about it.
 
.get(0) is just a douchey way to say [0]
 
@Esailija ehhh I dont like accessing it via [0] which could lead to errors. .get(0) returns false if the jQuery obj is empty
 
You gotta use .eq(0) to be like an upper-level at-club-with-money douche.
 
which is useful @ErikReppen ^
 
lol
 
10:01 PM
@ErikReppen lol eq(0) returns the jQuery obj. you ddnt want that :-P
 
how does [0] lead to errors where .get(0) doesnt
 
Oh, right. I forgot.
undefined vs false?
 
how is false better than undefined
 
you should not have any code so that it could be false in the first place
so now I know where the () comes from
people are used to write strings like "callFn()"
then ppl say that's evil, use .on
so they write $(elem).on( "click", callFn() )
 
10:03 PM
@Esailija hehe
 
eval is not evil 100% of the time
.innerHTML += is evil 100% of the time
nothing is as evil as .innerHTML +=
3
 
innerHTML is so not evil for basic building tasks.
 
you are missing the key point
 
document.onload - That line looks resurrected from a seriously ancient tutorial
 
that is the += combined with innerHTML
+= is not evil on its own
innerHTML is not evil on its own
put them together....
 
10:05 PM
Oh... sorry. MIssed that.
Yeah that seems like it could get pretty heavy.
 
the onload event occurs when all content has been loaded. it would be torture on the user. use document.ready
 
When is eval not evil though? Doesn't it start a new instance of the JS-interpreter in a lot of browsers?
 
when you really need to dynamically evalute code
simple example is for inlining callbacks which is huge optimization
 
Wouldn't a named function become a local var of whatever it got passed into?
 
.map( function(a){
      return a.name
});
the iterator function calls is 99% of the time used
what if you could just say .map( "name") and it would dynamically generate code that didn't need to use a callback
simplified example that has another workaround
 
10:15 PM
I've been a little puzzled by JITs and callbacks actually. Isn't the point of inline-funcs that they're optimizable when they're local (so no call-object mucking about). When you pass in a callback, can't a JIT just assume that's always the same function being referenced for a given outer-function call?
 
no functional iteration is slow
for now
so consider this
function map(array, cb) {
    var cb = cb.toString();
    cb = cb.replace(/^.*?{/, "").replace(/}.*?$/);
    cb = cb.replace("return", "__ = ");
    var ret = [];
    var __;
    var paramName = "a"; //Could be parsed from the function
    var a = "for( var i = 0; i < " + array.length + "; ++i ) {var " + paramName + " = array[i]; " + cb + "; ret.push(__); }";
    console.log(a);
    eval(a);
    return ret;
}
very rough example to make a point
you can see it dynamically runs a normal loop like this:
map( a, function(){
    return a.name;
});
it would decompile and run this code:
for (var i = 0; i < 1; ++i) {
    var a = array[i];
    __ = a.name;
    undefined;
    ret.push(__);
}
instead of calling the callback for each iteration
which for a huge array would be much faster
then there's custom languages
say you invented something like JSONQuery or whatever bullshit
you would say "SELECT * from x" and it would turn it into javascript and eval
that is faster than creating some language runtime running on top of javascript
 
Okay but I thought the newer JITs like Chrome's basically reduce an inline function to something resembling more of an operator where the build-up/tear-down process is avoided when a function is within a local scope.
 
it's surprisingly fast though, I would have expected like 800 op/s
well good night
 
10:37 PM
Good night.
Wow, I had no idea parens in constructors were optional.
 
11:19 PM
Hi im getting this wierd error with bootstrap
Object [object Object] has no method 'dropdown'
Any idea?
 
@HarryBeasant Do you have any code?
And did you include bootstrap-dropdown.js?
 
yes
<div class="btn-toolbar">
<div class="btn-group">
<button class="btn dropdown-toggle" data-toggle="dropdown">Options<span class="caret"></span></button>
<ul class="dropdown-menu">
<li><a href="del"> Action 1</a></li>
<li><a href="details"> Action 2</a></li>
<li><a href="edit"> Action 2</a></li></ul></div></div>
</ul>
</div>
</div>
</td>
</tr>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<link href="css/bootstrap.css" rel="stylesheet">
<link href="css/bootstrap-responsive.css" rel="stylesheet">

<link href="js/bootstrap.js" rel="stylesheet">
working now
 

« first day (660 days earlier)      last day (4305 days later) »