Overheard at the office: “I can do it easily in Java, so I should be able to do it in Angular”. Riiiiight. That’s like saying “I can untie my shoes so I should be able to diffuse this bomb”.
And then later…
// set copyright year
So I wanted a different way to do it. I looked at using an empty tag (<var id=”thisYear” />) but Firefox doesn’t seem to like that, because it was swallowing up text behind that. I did a search for empty tags and found this article on empty elements.
The question arises whether “Tags for Empty Elements” in XML, i.e. things like <hr /> (or <hr />), really comply with SGML rules. The SGML Handbook seems to say they don’t. The start tag syntax there (p. 314) says that between the tag name (“generic identifier” in SGML terminology) and the closing “>” (“tagc”, for tag close), only attribute specifications and whitespace is allowed.
So it seems that XML empty tags don’t really comply with SGML rules!
So what is Firefox really doing?
var i = 10000,
j = 0.1,
k = /[\w]/,
m = new Array(1, 2, 3);
var i=1E4,j=0.1,k=/[\w]/,m=[1,2,3];throw 0.1;
var i=1e4,j=.1,k=/[\w]/,m=new Array(1,2,3);throw.1
In UglifyJS’s README it states that Google Closure “runs terribly slow”. Why is this an issue? Won’t you only compress when pushing to prod?
Ok browser makers. Let’s start over. I don’t think any site is using the navigator.appVersion anymore so now is as good of time as ever to start fresh. What do you say?
I didn’t know this!
null value … can only be assigned by your code.”
This will alert “10”:
var num = num || 10;
But so will this:
num = 0;
var num = num || 10;
Watch out for the cases where
num is “falsey“.
“… if you try to return anything [from a constructor] that is not an object [emphasis mine], the constructor will proceed with its usual behavior and return this.”
1. I have used <!CDATA[…]> sections when I’m embedding “<” and “>” but I think that’s just because I’ve used XSL before and they have caused problems when performing transformations. But I’ll try to remove it from my HTML as he suggests.