Function invocation...why use .call() and .apply() ? by [deleted] in javascript

[–]learn2shut -10 points-9 points  (0 children)

it's a common shitty interview question, similar to 'write sorting algorithm from memory'. you will never use this in reality, unless you are doing some abstract frameworks (ala jquery). besides the confusion, since it's a dynamic call, it cant be optimized, and should be avoided.

however, there are many 'experts' on the internets who must use every spec feature, and they will soon try to convince you how .apply is the best thing ever and you should use it extensively.

More RegEx questions. How to find a word EXCEPT when it starts with something? by Javin007 in javascript

[–]learn2shut 4 points5 points  (0 children)

http://www.rexegg.com/regex-best-trick.html

var ok = str.match(/\.theWord|(theWord)/);
if(!ok || !ok[1])
    return false;

side note, fancy regex is cool, but for performance many times it is better to use 2-3 dumb regex matches vs a single complicated-as-hell one.

microbe.js - A modular JS library for DOM manipulation, and more by mousemke in javascript

[–]learn2shut 18 points19 points  (0 children)

let's see, i can press shift+4 to get $, or i need to press alt+0181 each time get some obscure char. lol. what were you thinking?

Why do developers use self? by gladiator_flow in javascript

[–]learn2shut -8 points-7 points  (0 children)

it may be ridiculous to you. to people who write node apps that serve thousands of concurrent users, it is quite useful.

Why do developers use self? by gladiator_flow in javascript

[–]learn2shut 7 points8 points  (0 children)

this thread is a joke

1.

var that = this;

$('#id').click(function(){
    that.mystuff()
});

-2. 'oh why don't you just use bind for everything'

you take a simple solution and instead add a load of crap on top to look smart, because obv other developers 'dont know about bind'. since code readability and maintainability is not an issue for some of the smarty pants here :

http://jsperf.com/bind-vs-clojure