« first day (2047 days earlier)      last day (2895 days later) » 

7:00 AM
@techie_28 yes, but calling a function is not a function declaration
A function declaration is: function () { }
 
not exactly. that is a function statement
 
@Neil you mean to say in my example I will have to pass whole function body if want to use Function constructor & not just the name?
 
and it is illegal. function statements cant be anonymous
parentheses around it would make it a legal function expression though
 
@techie_28 to use Function, yes
@doug65536 Function doesn't take an expression
 
@Neil but eval wont need it right?It checks for function definition in the script but a Function constructor does not?
 
7:02 AM
o/
 
I am not talking about the Function constructor
 
@doug65536 I am. ;)
 
there are two syntaxes for functions: statements and expressions
function thisIsAFunctionStatement(a) { return a+1; } var b = function() { console.log('this is a function expression'; };
 
@doug65536 then I misused the term "declaration"
 
@doug65536 no
no
Both of them are expressions
 
7:05 AM
no
 
@Neil am I correct in my last assumption?
 
!!> var lol = function rofl () { console.log("LMAO") }; lol(); rofl();
 
@techie_28 right. Using eval is the equivalent of running it from the console directly
 
user3119231
@littlepootis haha
 
7:07 AM
@littlepootis do you know what a statement is?
 
@doug65536 Yes, I do.
 
then what's the problem
 
I would strongly advise you to find the proper solution to your problem once you have the time, @techie_28
 
@Neil thanks
 
one is a statement, one is not
 
7:07 AM
The former example is also an expression.
 
var b is the statement, which evaluates an expression on the right hand side of the = in var b = ...
 
function () {} and function lol () {} are both expressions.
 
no
they aren't
 
@Neil I understand your point
 
try it
 
7:08 AM
dude
 
Give it a try
 
@techie_28 nod
 
you said same thing twice
 
@Neil Window[funDef]() will also work if that function is in the global scope?..
 
and no, neither of them are expressions. sorry, you don't know what it means
 
user3119231
7:09 AM
@littlepootis man he's canadian - probably rlemons brother. Shut up, dude.
 
@doug655 What do you think function lol () { console.log("LOL"); } evaluates to?
Does it evaluate to something? If yes, what is it?
 
it evaluates to nothing, it gets hoisted into the symbol table in the function where it is defined
now, if you referred to that symbol as an rvalue, then it would evaluate to a closure for that function
 
Now try assinging it to a variable.
 
@techie_28 if funDef is the name of the function yes
 
a function statement is guaranteed to be callable anywhere it is reachable
a function expression must be evaluated to be reached
I'll show example to hopefully make more sense...
 
7:12 AM
@doug65536 Not since ES2015, IIRC.
 
Next room topic: how many angels can balance on the head of a pin?
 
how did it call example? example didn't "run" yet
and how did example() call magic() before the function?
 
user3119231
@Neil I see what you did there ;-)
 
because function statements are not the same as function expressions
 
7:13 AM
function lol () { [..] } is an expression..
 
it isn't
for (var i = 1; i < 2; ++i) function lol() {}
does that make sense?
 
Since when..
 
no
 
@Maurice I am genuinely surprised that anyone got that :D
 
I'm on my mobile, so I can't really run any code and test, but I'm pretty sure it is.
 
7:14 AM
if you did a = function() {} then the function is a function expression
man, I should stick to IRC for web stuff
 
What if you did a = function b () {}
 
that is an expression
 
Under what circumstances would the use of eval be considered 100% safe??
 
@littlepootis yes, just like 1+1 would be
it's not a big difference. If you had var x = function() { }; then it would have to execute that line before the function is reachable. and you can only reach it as x
 
user3119231
Let's stop make war and start make love:
 
user3119231
 
but... if you had as a statement function x() { } then it is callable anywhere in that scope, regardless of what ran yet
 
@Maurice Buy me dinner first
 
it's just a quirk of how it parses function. you can assume that, before it executes any code in a function, it has dug through the function body and processed all the var statements and function statements. it ignores function expressions, which are rvalues
var and function (statements) both add symbol names to the current scope
 
Of course.
Someone bring cap back pls.
!!live
 
user3119231
!!summon @CapricaSix
 
user3119231
7:19 AM
this was the stupid(est) thing I did today.
 
@techie_28 in a debugger, executing a console command from the developer
you never need eval in js. it has far too powerful object access capabilities
var a = { foo: 'x' }, b = a.foo, c = 'foo', d = a[c]
when you think you need eval('a[' + i + ']') you are a fool that needs a[i]
I found some ancient netscape js I wrote in the 90's, that did exactly the foolish thing
if you want lookup tables, just use [] indexing on an object, like d in my example
 
user3119231
btw anyone noticed that ctrl + f4 doesn't work anymore?
 
try ctrl-w
if you mean close tab
 
user3119231
yeah this works, of course
 
Hai, i´m working with React & Webpack. The building process from when I change code to see it live does take over 3 min. Can someone tell me how to decrease the time or what I should do for a better dev experience?
 
7:30 AM
the machine takes 3 minutes? or some mysterious delay prevents you from seeing changes for 3 minutes?
 
@doug65536 how does jQuery ajax evaluates a script response?When dataTye:'script' is there & response has a JS code enclosed in single or double quotes?Does it not use the eval function internally?
 
no, from hit the npm start script to "webpack: bundle is now VALID."
does take 3 min
I just have 4 components with 8 lines of code in each
 
@techie_28 depends. If you want to invoke a block of js that you trust, then sure, use the expression form of eval, like this: (eval)(scriptCode)
 
"scripts": {
    "start": "webpack-dev-server --inline --content-base ."
  },
 
but, they actually construct an actual <script> tag and append it to the document
it only has to be in the document until the load finishes, then it is removed
roughly $('<script/>', { src: src, appendTo: 'head', on: { load: function(this) { $(this).remove() } });
 
7:34 AM
@doug65536 so that is how jQuery handles it?
 
one sec I'll see if I can find the actual jquery code...
 
Hi guys
 
Um.. @doug. What does the typeof operator expect at its operand?
 
is it possible to the set the .style of a Node in this manner?
this.layer.style = Object.assign( {}, {
    zIndex: ThemeProps.zIndex.layer,
}, style );
 
@littlepootis an expression
 
7:36 AM
Why does this work?
typeof function v () {}
 
because when it is parsed there, it is a function expression
 
please?
 
you know how if won't work anywhere except certain places? that is where statements are accepted
 
@doug65536 jQuery.ajax({'url':'....',dataType:'script',success:function(resp){//resp will be script here..will it be executed by itself?I guess yes}})
 
7:37 AM
if you say function where if is allowed, it is not treated the same as if you say function where unary - is allowed
function f() { } < --- that "does something" when the parser hoists all the var and function statements during parsing
var b = function() {}; <-- that does something when this line actually executes
 
@doug65536 wat?
 
@Neil var a = if (1) { wth(); }
won't work right?
because if is a statement
 
It won't
 
so is function, unless used where it requires an expression
 
@doug65536 no, because you put a statement where an expression should go
 
7:42 AM
you guys really don't know about hoisting?
 
i got an issue when executing following route in angular js
 
I've been arguing that BOTH of them are expressions.
 
We do. That doesn't mean you don't talk nonsense
 
They're statements too.
 
.when('/history', {
    title: 'History',
    templateUrl: 'views/history.html',
    controller: 'historyController',
    resolve : {
        getCallHistory : function(callHistoryService){
            return callHistoryService.get();
        }
    }
})
 
7:42 AM
You can place functions in expressions though
 
20 hours ago, by Mathematics
I don't think anyone here knows JS
 
app.service('callHistoryService', function(db){
  var calls = [];
  var _self = this;
  _self.set = function(results){
      calls = results;
  }
  _self.get = function(){
    return calls;
  };
  db.find('call_flow', {} , function(err, results){
      _self.set(results);
  });
});
callHistoryService doen't return value to resolve
 
@Neil yes, then it is a function expression, as opposed to a function statement
I know how to say it
 
which callHistoryService.get(); is undefined
 
The correct term for function lol () {} is a function declaration. And in var lol = function () {}, function () {} is a function expression.
I've never heard someone say "function statement" before.
Ha, now I have access to a PC :D. But.. Windoge.
 
7:45 AM
And yet I would understand "function declaration" being meant by "function statement"
 
A function definition (also called a function declaration, or function statement) developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions
 
@JanDvorak could u pls help me ?
 
He will. Just not how you'd like him to.
 
@underscore 1) stop begging random people for help. 2) stop speaking with letters when you mean words.
 
7:46 AM
you helped me previously
 
*helped
 
function magic is parsed as a function expression, so it does not participate in hoisting, and therefore isn't guaranteed to be defined before that scope starts execution
when it was a function statement, magic() can be called anywhere in there, before, after, ahywhere
 
that name I gave it is only usable for recursion from inside the callback (because it is a function expression)
 
Also, that space before the question mark is pointless.
 
7:48 AM
Oh.?
 
@underscore Just pasting code that doesn't run into a jsfiddle doesn't help anyone
 
Also, have I said already I'm employed now?
 
@OliverSalzburg does it hard to understand my fault ?
 
*Is it hard
 
pls help me with this
 
7:50 AM
@underscore this refers to the window object. you are adding .find to window?? nevermind
 
Your fault is that you're a vamp. Your mistake is that you pinged a random stranger for help. Your bug is unknown to me because I don't do Angular.
@underscore *Please
 
it's a db service @doug65536
 
yeah you left out stuff so I parsed it wrong
 
@doug65536 have fun ;)
 
7:52 AM
i injected it to the callHistoryService
 
experts dont post on SO because, while writing their question, they narrow it down and find the bug, select-all delete their question, and close SO
aka rubber duck debugging
you think about what the rubber duck thinks, he's questioning your assumptions, breaking you out of your assumptions that you thought you didn't make
 
I've already "found" a bug in Canvas this way, only to discover the MCVE wouldn't reproduce it, and then why.
 
@doug65536 Experts don't post on SO because they're not interested what some guy from India, with broken English, on the hunt for rep has to offer on their problem
 
@underscore that's not an MCVE
 
7:56 AM
inb4 flags
 
:30725129 Aw, I missed it :(
 
@underscore that isn't complete
 
Microsoft Certified Visio Engineer
 
@underscore your code has a race condition
 
So, have you heard about that vegan woman who wanted to climb mt. everest to prove that vegans can do everything?
 
8:00 AM
that's mean?
 
wow
@underscore no
 
@doug65536 that's racist!
 
nothing prevents line 30 from running after you call .get
 
What does that mean?
 
8:01 AM
nothing prevents .get from running to completion too early before the find finishes
use promises
never cheat and stick it in a variable. it doesn't work
don't waste your time
 
inside the callHistoryService ?
 
Also don't use .service like that, it's nasty :P
 
@OliverSalzburg exactly, use .please instead
 
@underscore Wait, you want to know what "race condition" means? Or if he's being mean to you?
ed*
 
mongo returns a promise
so.. in that code I showed you, you return a promise all the way up. so the caller uses .then(function(callHistory) { ... }) to get the value asynchronously
I think angular will see that it is then-able and will handle it correctly. not 100% sure on that part
you can return a promise immediately, long before the request even starts, let alone finishes
it is used to get the result, when it finally becomes available, passed into .then callback
 
user3119231
8:09 AM
'le wild @Neoares spotted
 
sup @Maurice o/
 
user3119231
a lil working and you?
 
just arrived to the office
 
@BartekBanachewicz Or use .factory with a proper factory method, or return a constructor with .service, but not some nasty function that dynamically attaches stuff to this :P
 
gotta work on my own advertising videoplayer
 
8:12 AM
:D
 
@OliverSalzburg I am trying to figure out why some people do that too... early angular ??
 
@BartekBanachewicz lmao
 
@BartekBanachewicz credit to blizzards modelers ;)
 
is there nude stuff in overwatch?
or just something sexy so that some little boys couldn't prevent their hand to touch their stick?
 
@OliverSalzburg I've seen projects where they do that everywhere, and if I even touched $scope it broke everything. glad I was just helping some guy with some random code
 
8:15 AM
You can still skin the models.
Not literally, but still.
 
@doug65536 No idea. Probably the fault of some SO answer that turns up when you google "how to angular service"
 
@KarelG no, just that some of the female characters are, well-endowed
 
ah the latter then.
 
@KarelG photorealism backfired
 
define "backfired"
 
8:20 AM
touche
 
@BartekBanachewicz lol is that real?
 
@Neoares of course
 
Anyone catch the last got? No spoilers, but my eyes were bawling at the end
 
anyone know what version of IE supports $.inArray ?
 
Depends on your jQuery version
 
8:26 AM
@KirstyMarks of IE? is that a typo?
 
ok, you may have answered my Q there
nope :s
 
jQ2.0+ IE9+, jQ1.9 IE6+ IIRC.
 
ty @roelvanuden you may have just confirmed itfor me
for me*
 
@KirstyMarks if it is pertinent enough, you should consider testing it
 
Something wrong with haystack.indexOf(needle) >= 0
 
8:28 AM
Only way to be sure
 
yea that works fine,
we were looking down potentially the inArray route also
 
@doug65536 is there?
 
@doug65536 -1. Not enough jquery.
 
no, just saying native js has inArray equivalent
 
oh, right oh, gotcha
 
8:29 AM
Well, it's less readable :-D
though still beats ~haystack.indexOf(needle)
 
@JanDvorak the only reason I think indexOf is better is because there is no doubt that you got the order of parameters right with my version
 
meh.
 
@doug65536 because the order of parameters might change with jquery?
 
Named parameters FTW
 
@Neil no, because you might be wrong
it is backwards
 
8:32 AM
atan2({x: x, y: y})
 
like the backwards .each callback, that takes index as first parameter, opposite of Array.prototype.forEach, because they wanted to use this for the value too, so value went second
 
@doug65536 that's a reason not to switch to or from vanilla from to jquery
 
totally error prone. with jquery .map it is an issue too... you might think it is array map not jquery map
 
Not a reason not to use the jquery version in of itself, and certainly not the reason why I wouldn't use jquery
 
8:35 AM
$('.foo').map(...) is obvious, but not thing.map(...)
 
ty @karelG
 
I am just saying, with those completely redundant jquery things, I advise using the real ones in js
imho, ymmv, ianal
 
!!urban ymmv
 
your mileage may vary
 
your mileage may vary
i am not a lawyer
 
8:37 AM
!!urban ianal
 
I am not a lawyer
 
Yay, I have written my first human based program
 
Watch this
 
@doug65536 $("#mom.your").imho("fat")?
 
8:40 AM
!!urban lmao
 
@Neil laughing my arse off
 
Yay!!
 
user3119231
wtf happened here
 
@OliverSalzburg implying that it wasn't there before the standard. They were always there
well, some were
 
8:43 AM
hi guys, was wondering about es5/es6 syntax for functions in dictionnary without implicit return. Something like {how_many_things() => get_all_the_things().length}. But it looks like that's not the correct syntax
 
@doug65536 Just adding information. No IE8 support! Boooo!
 
many things standardized were actually just standardization of things every browser already did
 
{how_many_things() { return get_all_the_things().length; }} works of course
 
in an object literal?
 
@OliverSalzburg well yeah missing stuff. But Array.prototype existed from day 1 of js (even if it was accessed some slightly different way)
 
8:45 AM
Jan: yup
 
() => ... is a function expression, you have to assign it to some key.
 
ah ! yeah, I should do { func: () => myreturnvalue } !
(so much pain for the guy doing a javascript parser)
 
It's not a single guy
 
I know I know :D
 
JS was created in 10 days in May 1995 by Brendan Eich
 
8:48 AM
The spec, not the parser
 
you can make a js parser in one day
 
@doug65536 Just use eval
 
hum...maybe with the early js syntax but...with shorthand function there's so much ambiguity
 
do semantic analysis for var and functions, setup closure scopes, interpret AST, done
 
+ optional semicolon....optional semicolon !
 
8:49 AM
it's actually a pretty simple language. easy to interpret
the only non-trivial thing is dealing with closures and circular references
 
Then someone throws an eval at you and you're screwed
 
....I believe you should look at lisp-like languages to see easy-to-parse languages
 
@JanDvorak no, because I already have a "parseJSFromString" if I implemented a js engine
 
@damio brainfuck
 
you just parseFromString(js).invoke() or the moral equivalent
 
8:51 AM
Jan +1
 
A noob hello to you from me!
 
eval is easy, its scope chain is just the global scope
no closures involved
 
unless you use it directly
 
wait no
 
eval can easily mess up your scope analysis
 
8:55 AM
modern js engines throw up their hands and interpret when you do that. it disables compilation
besides that, the compilation process of js gets quite a bit of information out of the script, for a dynamic language
it "knows about" the reachability of every var, because it needs to know for closures to work
it's not like many dynamic languages that are oblivious except one line they are executing, then they lookup symbols right then and there every time
 
until you use eval in any enclosing scope
 
user3119231
"add is not defined" - What did I miss? jsfiddle.net/210buu9L
 

« first day (2047 days earlier)      last day (2895 days later) »