« first day (297 days earlier)      last day (3491 days later) » 

19:03
@SomeGuy thanks, wonder why it didn't work?
!!s/figuring/fingering/
@BillyMathews No matching message (are you sure we're in the right room?)
Yeah, Zirak says that both moustache and the replacement function work only in the parent room
That is, the JavaScript room
Is it set to be like that or is there a reason it only works in that room (if you know)?
@BillyMathews The sed only works in the main room because it uses the DOM
@rlemon can you link me? I can't find it
19:06
Nevermind :p
/mustache because it needs to grab the gravatar url, and that info isn't easily available to non-main room.
Relative luminance follows the photometric definition of luminance, but with the values normalized to 1 or 100 for a reference white. Like the photometric definition, it is related to the luminous flux density in a particular direction, which is radiant flux density weighted by the luminosity function \overline{y}(\lambda) of the CIE Standard Observer. The use of relative values is useful in systems where absolute reproduction is impractical. For example, in prepress for print media, the absolute luminance of light reflecting off the print depends on the illumination and therefore absolut...
the article I actually read
@Zirak ah, thanks for clearing that up
@rlemon thanks
also @Zirak when you hit the discussion you will see the glaring false statement I made. just roll with it, i'm trying to get them to stop using the 'new' keyword :P
when they eventually learn about it, they will realize I lied.
I read about it when you said that
you linked us to an answer on SO that explained it
19:09
well I lied and told them it doesn't call the constructor function.
so the literal notation does call the constructor function? (if so you had me fooled)
In php, you should use [] instead of array in new code, but just because it's nicer.
In JS, Array is also slower than a literal because of the extra lookup, but that's not as important as readability.
@BenjaminGruenbaum Readability over performance? I'm not sure I agree
You will once you see a large enough codebase.
@BillyMathews it's better in both. Also, wat?
Go read a programming book or somethind :D
19:13
At the end of the day I'd rather my script ran faster
anyway
Because nobody reads code
So it's better to use ~arr.indexOf(item) than arr.indexOf(item) > -1
ohh yea.
CANADA WINS
am I getting confused in saying that if you don't use 'new' keyword for Array you don't get any of the class' prototypes?
from this answer
@BillyMathews Array does that for you es5.github.io/#x15.4.1
I meant literal notation
19:25
Relevant part of spec: es5.github.io/#x11.1.4
From your experience, do arrays created by array literals have array functions?
!!> [0, 1, 2].pop()
@Zirak 2
That should answer your question.
Ok
I'm confused because @rlemon told us not use new and then he said he lied about why, so now I don't know why xD
for arrays and objects specifically I told you not to use 'new'
use array/object literal notation
yeah i know
why?
19:32
1) more concise
2) faster to write
3) more convenient in most cases
using the 'new Array()' syntax show me how you would make an array of words. 'foo', 'bar', and 'baz'
then show me how you would make an array containing only one index. the number 42;
$arr = new Array('foo', 'bar', 'baz');
amirite?
$arr is php thing but yea.
now the 42
$arr = new Array(42); //this might not work?
and yeah sorry var arr = ...
that will create an array with 42 undefined s
var arr = new Array();
arr[] = 42;
19:34
try it
I see where this is going...
var arr = new Array();
arr.push(42);
um, can I use chat bot to do that?
is the solution there btw
var arr = new Array();
arr[] = 42;
SyntaxError: Unexpected token ]
you can't set an undefined index?
have I been smoking something funny
19:36
you can set any index you want, but it makes a sparse array which you probably don't want.
arr[0] = 42; would also work, but likely isn't exactly what you want your array to do
but arr[] = 42; throws a syntax error?
yes
this isn't php :P
I thought you could do that and it automatically appends it after the last set index
is that only PHP..
that is what push does :P
I haven't JavaScripted in a while :P
19:37
arr.push(val); // pushes the value on the end.
I've been honing my PHP
so
using literal
var arr = [ 42 ]; ?
winner!
:P
var arr = ['foo','bar','baz'];
would be the other one fyi
but then you can make more interesting structures easily.
var arr = [
	{
		foo: 1,
		bar: 2
	},
	{
		foo: 2,
		bar: 3
	},
	// ....
];
20:00
2014 Moderator Elections: Vote Now! (final voting)
5
@rlemon could you use anything? say a function (for a return value) or a new object?
@BillyMathews you can do the object literal notion like that iirc.
var array = [ someFunction(), someOtherFunction() ];
not on an array, but an object.
var billy = {
  sayHello: function () {
     console.log('hi');
  },
  sayGoodbye: function () {
     console.log('good bye');
  }
};
then if you need to add new functions to it, you extend billy. You can even create new new billy's with: var dave = Object.create(billy);
which is pretty close to how new would work, the prototype chain remains.
iirc.
My pattern is having a create or new function on an object, which basically calls Object.create and does any necessary initialisations (and pascal-casing the "prototype" object)
20:12
var someFunction = function(){
    //generate random number (cba...)
    return randomNumber;
}
var arr = [ someFunction(), someFunction() ]; //generate an array of two random numbers
@Zirak code on github is a great read for stuff like this.
@BillyMathews I would imagine the function would generate the array, you just tell it how many random numbers to create.
var Billy = {
    new : function (age, location) {
        var ret = Object.create(this);

        ret.age = age;
        ret.location = location;

        return ret;
    },

    sayHello : function () {
        console.log('hello, %s/m/%s', this.age, this.location);
    },

    sayGoodbye : function () {
        console.log('g\'bye');
    }
};
Then it's var boy = Billy.new(14, 'Kansas')
@mikedidthis I thought of that when I was writing it, but as an example, would that work?
@BillyMathews Give it a shot.
^ that.
20:15
20 hours ago, by rlemon
var me = Object.create(Person.prototype);
me.name = 'rlemon';
me.gender = 'male';
@Zirak so I don't need to pass in the prototype?
If it's not a function, 'course not.
well I suppose that makes sense :P
@Zirak that works
That's because each item in the literal syntax can be any expression.
20:55
anyone good at github?
What's a line ending?
> If you develop in a cave, on a single platform, and don't share your code with anyone then you can happily move on and not worry about line endings because the default settings in Git will suit you just fine. The rest of you, read on!
This is me, but I want to know!
!!tell BillyMathews google line ending
Thanks
that had me baffled
for some reason

« first day (297 days earlier)      last day (3491 days later) »