|
Being a student of the Western Esoteric Tradition, e.g. a first degree mystic, I give you ten out of ten for that.
|
|
|
|
|
A heartbeat is, and is not.
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
--Winston Churchill
|
|
|
|
|
yep, but, a heartbeat has rhythm; if it loses the beat, your are not well.
«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008
|
|
|
|
|
What does
return
{
a: "hello"
};
return?
(See A Collection of JavaScript Gotchas[^] for a hint.
I love finding something new about something I thought I understood.
cheers
Chris Maunder
|
|
|
|
|
doesn't it return?!
{
a: "hello"
}
The only confusion I can foresee is about what is this for the returned object...
Gotta read your link for hint on the trap!
|
|
|
|
|
The followup question is:
What does this return?
return {
a: "hello"
}
cheers
Chris Maunder
|
|
|
|
|
|
Super Lloyd wrote: I fail to see the tricky bit
Exactly.
Now try
return
{
a: "hello"
}
instead of
return {
a: "hello"
}
and let me know the difference.
cheers
Chris Maunder
|
|
|
|
|
OMG!!!
Yes, that's Javascrupt for ya!
|
|
|
|
|
...and this is why JavaScript needs to be retired in its current form. It's simply too loose a language.
cheers
Chris Maunder
|
|
|
|
|
Wow, so mere spacing can make a difference? Wtf! How do they even minify this with any expectation of consistency?
|
|
|
|
|
Nah, we just need to deprecate ASI. The community already shuns it, and I'm sure no one would bemoan its loss. Lots of JS devs are already fine with sticking 'use strict'; in all of their code. Let's just leverage that as a flag to tell the JS engine to turn it off.
modified 10-Oct-16 10:28am.
|
|
|
|
|
TypeScript FTW!
|
|
|
|
|
cheers
Chris Maunder
|
|
|
|
|
That's insane, Chris! You should make it a high priority to rewrite the site going back to VBScript. It worked fine then, and there's no reason that it would not work today, other than the overhead required to serve an additional 12 million members.
Will Rogers never met me.
|
|
|
|
|
Great findings there, Chris. I didn't know that it would make a difference when returning an object.
When writing JS code, I always do the K&R style of coding because I find it more clean and compact. I also do the same indention style with C#.
|
|
|
|
|
The tricky bit is here:
https://jsfiddle.net/vzmh2eL6/1/[^]
Returns `undefined`
Same thing happens if you use any other expression like:
return [1,2];
vs
return
[1,2];
This happens since based on Standard ECMA-262 5.1 Edition section [^]:
return [no LineTerminator here] Expression ;
we can not have any line terminators or new line between the return and the expression. If Expression is omitted, the return value is undefined. Otherwise, the return value is the value of Expression.
Hope it helps!
Regards,
Palash
modified 10-Oct-16 2:07am.
|
|
|
|
|
|
Palash Mondal_ wrote: This happens since based on Standard ECMA-262 5.1 Edition section [^]:
Actually, it is since the very beginning (v1.0). The end--of-line terminator was to help VB programmers; but it has caused all sorts of problems.
The issue is that there are effectively two forms of the return statement ...
return and
return expression;
|
|
|
|
|
You might like to see the difference between
var x =
{
a: 'Hello'
};
and
if (x)
{
a: 'hello'
};
The first creates an object (x) with a property (a) with a value ('hello')
The second is a statement with a label (a) pointing to an expression ('hello') which does nothing. Labels (except for case labels) are a feature that have never had any practical use in JavaScript.
|
|
|
|
|
Neat link, Chris! And an excellent job of discovery by Jonathan!
Will Rogers never met me.
|
|
|
|
|
Chris Maunder wrote: A Collection of JavaScript Gotchas
"The string replace function only replaces the first match, not all matches as you may expect"
This one took me like forever to find out . I have never coded in Javascript, but recently for some Google Forms scripts...
|
|
|
|
|
I think that's easier to see coming - I figured the reason out for the JavaScript in a second - than that these two records will be inserted with no error in MySql, where we have unique index (Name, Sex) :
Name Sex
------ ----
Brady null
Brady null
From the manual:
In MySQL, a UNIQUE index is one in which all values in the index must be distinct. An error occurs if you try to add a new row with a key that matches an existing row. The exception to this is that if a column in the index is allowed to contain NULL values, it can contain multiple NULL values. This exception does not apply to BDB tables, for which an indexed column allows only a single NULL.
|
|
|
|
|
Anybody had their hands on it already? Just started my very first baby steps with it, and I can say I like it so far. Host an ASP.Net MVC app in the console - That surely is neat to have, especially for smaller web apps / services.
JavaScript gives you a false sense of safety. It's like riding a bike with those little side wheels and then riding head first into a ravine.
Sander Rossel
|
|
|
|
|
Yes - we've been using it for a while on a side / play around project we'll be releasing soon and it's definitely has it's ups. And its downs.
Core 1.1 is what I'm waiting for, patiently. The changes with Core over the RC period was painful, but I'm very much looking forward to a fully platform independent codebase. Sorry Microsoft, but I'm tired of paying OS licencing. (and, frankly, tired of Bootcamp - being able to work on the same code on my Mac will be great)
Now if only the million, billion frontend frameworks, tools and libraries would settle down.
cheers
Chris Maunder
|
|
|
|