These are chat archives for codefellows/sea-c16-javascript

18th
Jul 2014
sunny yuen
@yuens1002
Jul 18 2014 15:28

i don't understand why the order of the function call inside the

_.compose(greet, format);

DOESNT matter...

var realNameMap = {
  'pebbles': 'penelope'
};

var format = function(name) {
  name = realNameMap[name.toLowerCase()] || name;
  return name.charAt(0).toUpperCase() + name.slice(1).toLowerCase();
};

var greet = function(formatted) {
  return 'Hiya ' + formatted + '!';
};

var welcome = _.compose(format, greet);
Martin Genev
@mgenev
Jul 18 2014 16:30
@yuens1002 you could open the function definition and find out i'm sure ;)
in the underscore sourcecode look for .compose and see how they handle it
the truth is the docs really make it sound like it does matter...
Martin Genev
@mgenev
Jul 18 2014 16:52
// Returns a function that is the composition of a list of functions, each
// consuming the return value of the function that follows.
_.compose = function() {
var args = arguments;
var start = args.length - 1;
return function() {
var i = start;
var result = args[start].apply(this, arguments);
while (i--) result = args[i].call(this, result);
return result;
};
};
hmm how do you guys paste code so nicely
Hailey L. Petway
@hlpetway
Jul 18 2014 16:54
use three ``` to open and close the code I think
Martin Genev
@mgenev
Jul 18 2014 16:56
{code}
sweet
thanks
Ivan Storck
@ivanoats
Jul 18 2014 17:07
also
โ‡งโŽ (shift-enter)
can make multi-line
messages. So put the on a single line, then โ‡งโŽ and finally close with on a separate line
arg.. how to escape the back ticks?!
```
backslash, of course ๐Ÿ˜
Hailey L. Petway
@hlpetway
Jul 18 2014 17:07
Is there a cheat sheet for this? I'd like to bookmark it :)
and for more cool stuff
Joe Elsey
@joeelsey
Jul 18 2014 18:12
So we're definitely supposed to use node for assignment 5.1?
Oh. The required reading link for 5 is 404 atm.
Martin Genev
@mgenev
Jul 18 2014 18:24
@joeelsey you're not supposed, i just thought it's a good time to introduce it. if you copy/paste that link it should work
or google its title
Joe Elsey
@joeelsey
Jul 18 2014 18:26
Ah. Well then I just got some practice installing node again. Good times. Thanks.
Martin Genev
@mgenev
Jul 18 2014 18:27
node is good for you ;)
Joe Elsey
@joeelsey
Jul 18 2014 18:29
I'm happy I was able to install it without too much fumbling around.
Scott Romney Burbidge
@sburbidg
Jul 18 2014 18:29
fumble bee
I was gonna do both 4.2 and 5.1 this weekend. Any of you high ranking officials know which one would be better to get a merge request going for first or does it not really matter?
Martin Genev
@mgenev
Jul 18 2014 18:34
doesn't matter
Joe Elsey
@joeelsey
Jul 18 2014 18:39
Is there a best practice for traversing an array of object literals? .length?
Scott Romney Burbidge
@sburbidg
Jul 18 2014 18:39
fantastic. I shall make my own decision.
Martin Genev
@mgenev
Jul 18 2014 18:40
@joeelsey not sure exactly what you mean, but you can open the underscore source code and see how they traverse
jquery also has code for that
Scott Romney Burbidge
@sburbidg
Jul 18 2014 18:44
@mgenev Last time I had an open pull request it seemed like it was automatically adding anything I pushed to my fork to the pull request. That seems like it could cause problems in some cases.
Martin Genev
@mgenev
Jul 18 2014 18:45
yea github is a bit weird like that it lumps everything to the open request
you should have no problems as long as you stick to your own folder
Scott Romney Burbidge
@sburbidg
Jul 18 2014 18:46
Yeah, I was just thinking for bigger projects. I guess you probably just have to be careful what you send to your remote while you have a request open.
Martin Genev
@mgenev
Jul 18 2014 18:47
yep or use branches
branches is the best solution
Scott Romney Burbidge
@sburbidg
Jul 18 2014 18:50
Oh okay, so different branches won't go into the same pull request automatically. One day I will know all of the idiosyncrasies of github. Thank you
well, maybe not all of them
Do we need to add the code at the beginning of that link for our underscore functions to work?
BrockBeaudry
@BrockBeaudry
Jul 18 2014 19:57
in a script: '''var _ = require('lodash');'''
or loading the library from html: '''<script src="lodash_test.js"></script>'''
guess those should be backticks
in a script: var _ = require('lodash');
or loading the library from html: <script src="lodash_test.js"></script>
Martin Genev
@mgenev
Jul 18 2014 20:02
@joeelsey remember, the browser doesn't have dependency management to require external files like Node
so you either need to use a 3rd party one like require js
or to put everything in your html file
truly doing this stuff in node is easier
Matt
@mahenry926
Jul 18 2014 21:48
so in git, if i add some new code, create a pull request, then add some new code, do i have to recreate the pull request or am i good?
haha, i think i see now the question's answered above, sort of preemptively? :)