last day (27 days later) » 

2:03 AM
As the primary author of the library, I just want to make sure everyone is aware that it isn't avaible for release yet, and you must apply to access the source code. Contact me @ contact@muffinkingstudios.us
The library is designed to be a dot operator-based tool belt library for things you would expect to be in pure js. It is also supposed to be Compatible with Everything!
If you would like to red the source code, I will offer it to anyone who asks.
 
2:18 AM
Please stop doing === true and === false it's painful :(
 
What should I do instead?
 
if(x === true) for a boolean x is just if(x)
 
fair enough.
oh
 
if(x === false) for a boolean x is just if(!x)
if(x){
    return true;
} else {
    return false;
}
Is just:
 
so `if(x)` {
//bla bla bla
} else {
}
 
2:19 AM
return x;
 
would work?
 
Yes, === just returns a boolean.
 
Okay I'll do that then.
 
Doing bool === true is the identity function (doesn't do anything), doing bool === false is just doing !bool
 
Now you've confused me
 
2:21 AM
!!> var x = true; x === true;
 
@BenjaminGruenbaum true
 
!!> var x = true; x;
 
@BenjaminGruenbaum true
 
See? Doing x === true is the same as x
 
Okay I'll fix that then.
 
2:22 AM
That's not a fiddle and caprica is our bot at the JS room I summoned to show you how booleans work in the language
 
oh
and wrong link thanks
 
!!> var x = true; x === false;
 
@BenjaminGruenbaum false
 
!!> var x = true; !x;
 
@BenjaminGruenbaum true
@BenjaminGruenbaum false
 
2:23 AM
Same thing.
!!> (function(x){ if(x === true){ return true; } else { return false; }})(true);
 
!!> var x = true; !x
 
@BenjaminGruenbaum "SyntaxError: expected expression, got ')'"
@wyatt false
 
that's awesome
 
You should really learn the language before wrapping things with a library XD
 
@BenjaminGruenbaum true
 
2:24 AM
It was supposed to be a way to help me learn as I went
 
!!> (function(x){ if(x === true){ return true; } else { return false; }})(false);
 
@BenjaminGruenbaum false
 
@wyatt looks like it's working :D
 
xD
 
!!> (function(x){ return x; })(true); // better
 
2:25 AM
@BenjaminGruenbaum true
 
why'd you wrap function in that?
 
!!> (x => x)(true); // even shorter, but only works in new browsers
 
@BenjaminGruenbaum true
 
@wyatt well, it's called an IIFE, it's a very basic and fundamental concept in JavaScript - Immediately invoked function expression.
 
okay
 
2:26 AM
77
Q: What is the (function() { } )() construct in javascript?

ExitosI used to know what this meant but im struggling now... Is this basically saying document.onload? (function () { })();

 
I did code academy like 2 years ago, then tried to self teach myself from there.
 
I'm basically creating a function and immediately invoking it.
Read the good parts, it's a short book and it'll do you good :)
 
!!>(function myFunction(args) { return 7;})
 
@wyatt "function myFunction(args) {\n\"use strict\";\n return args;}"
@wyatt "function myFunction(args) {\n\"use strict\";\n return 7;}"
 
close enough
 
2:27 AM
You made a function expression but didn't immediately invoke it - JS (in ES5) has two way to create functions - function expressions and function declarations.
 
!!>function test(x) { return "test";} test(null)
 
@wyatt "function (x) {\n\"use strict\";\n return \"test\";}"
@wyatt "undefined"
@wyatt "ReferenceError: test is not defined"
@wyatt "test"
 
that's better
lol
 
That's a function declaration not a function expression.
Read "The Good Parts", it's a short read and it explains all this
 
Is there a shortcut for x === undefined?
Okay
 
2:31 AM
What's wrong with === undefined? A shortcut for what? What are you checking there?
Doing === undefined checks if something's value is undefined, it doesn't check if it's undeclared and it doesn't distinguish being passed nothing from being passed explicit undefined.
 
_$.isDefined
just wondering if there was a faster shortcut to what I did thats all
 
What does it actually do though?
 
returns true if the argument is undefined, vise verse.
no, the oppisite
 
You mean if the argument is equal to the value type undefined.
 
yeah
ooh I almost missed that discrepancy.
 
2:33 AM
You realize it'd still reference error on undeclared things and would return true for stuff that is defined to be explicitly undefined right?
 
it would give reference error?
How should I do it then?
 
You shouldn't, if you're in a position you might get a reference error get out of the position don't check.
If you just want to check if the value is explicitly undefined do === undefined
If you want to check if the value is truthy you can just do that directly:
if(obj){
    // obj is not undefined for sure here - works for objects (avoid with primitives)
}
 
The function was supposed to check if a variable was defined, useful to prevent cheating on games and stuff.
 
You can't prevent cheating on games - anything sent to the client the user can manipulate.
 
2:38 AM
What''s the html escape for '
I know, it was just supposed to be helpful
whatever I'lll remove it.
 
Don't hand-code escapes.
Here is a generic escape function that escapes what it needs and nothing more:
 
thats an  
xD
 
function safeEscape(content){
    var dummy = document.createElement("div");
    dummy.textContent = content; // assign for text content, the DOM will escape what it has to for you
    return dummy.innerHTML; // use the DOM parser
}
If you want an element with like breaks just use a <pre>
 
okay
Done removing my functions yet?
 
2:41 AM
@wyatt lol, I just think everything you have there can be easily accomplished without it.
Did you check out underscore/lodash? You can read their source code and learn a lot from it
 
Well then. . .
I read Jquery
Didn't understand 9/10 of it
 
Don't read jQuery's source code. It's horrible and messy :D
 
I beatified it.
stll messy
 
still*
 
2:42 AM
You can read it unminified in the source control repo on GitHub
I have a hard time following it and I've been doing JS for years - it's not hard just a lot of state and stuff in jQuery
Underscore is annotated - lemme find it
 
kewl
 
Thanks
 
Already found a giant scope issue with mine
totally forgot about that.
 
Okay
Gonna rewrite mine
Does this properly check the scope?
var _$ = function(obj) {
if(obj instanceof _$) return obj;
if(!(this instanceof _$)) return new _$(obj);
};
Wow
 
3:17 AM
!!> return true;
 
@wyatt "SyntaxError: return not in function"
 
!!> true
 
@wyatt true
 
!!> (x)
 
@wyatt "ReferenceError: x is not defined"
 
3:43 AM
 
 
3 hours later…
6:54 AM
-_-
 
 
6 hours later…
1:04 PM
!!> var x = 7; if(x) true; else false;
!!> if(x) true
 
@wyatt "ReferenceError: assignment to undeclared variable x"
@wyatt "ReferenceError: x is not defined"
@wyatt true
@wyatt "ReferenceError: x is not defined"
 
7
!!>"I'm Caprica Six"
 
@wyatt "I'm Caprica Six"
 
 
2 hours later…
2:45 PM
!!>7+10203 / 5 *76
 
@wyatt 155092.6
 
well then
 
3:02 PM
!!> "test"
Caprica
 
 
2 hours later…
5:18 PM
wyatt has added an event to this room's schedule.
 
 
3 hours later…
8:13 PM
What.
?
 
One sec
Updated script: jsfiddle.net/54xy2fq2
 
I have no idea what this library is supposed to do.
 
Same as before
toolbelt of things you'd expect in normal js.
Better than my original?
 
Still not very useful but ok
 
lol
 
8:21 PM
Read "The Good Parts"
 
where do I find it?
 
Local library, or Amazon
 
Licking 9v battery's is fun- ssube
2
i'm 12 :)
I'll look on amazon then @Benjamin
 
I really don't care how old you are :D
 
Mistype anyway
fail
 
8:29 PM
What'd you mean to type?
 
13
it's right next to the 2
I put that in a flag with it
 
Lol
 
Hey look, your library's popular now
 
8:33 PM
lol
 
user1596138
I am 12 years old
 
I am Spartacus
 
user1596138
Oh wait I was lying
 
I'm actually a unicorn
 
user1596138
Maybe the original user was lying as well.
 
8:36 PM
I mistyped, a lie there would be illigeal as well.
 

  last day (27 days later) »