Automatic semicolon insertion & return statements [duplicate]

The javascript interpreter/compiler is so smart to only insert automatic semicolons if afterwards there is valid Javascript. Your code works, because && b as it stands is no valid expression – that’s why no semicolon gets inserted after the return a resulting in: return a && b && c; However: return (undefined);//implicitely inserted { …. … Read more

Why are CSS named grid areas not in quotes?

The CSS Grid spec developers decided to use identifiers instead of strings, when defining named grid areas with the grid-area property, for the sake of consistency with the rest of CSS. The vast majority of CSS properties use identifiers, not strings, for their values. (Notable exceptions to this rule include font-family, content and grid-template-areas, which … Read more

Why does Array.prototype.push return the new length instead of something more useful?

I understand the expectation for array.push() to return the mutated array instead of its new length. And the desire to use this syntax for chaining reasons. However, there is a built in way to do this: array.concat(). Note that concat expects to be given an array, not an item. So, remember to wrap the item(s) … Read more

Regarding Promises/A+ Specification, what is the difference between the terms “thenable” and “promise”?

So What is the difference between the terms “thenable” and “promise”? I think the section you’ve already cited does answer this very well: A thenable is an object with a then method. Any object. A promise is an object with a then method (i.e. a thenable) that conforms to the specification. So far so simple. … Read more

What’s the use/meaning of the @ character in variable names in C#?

Straight from the C# Language Specification, Identifiers (C#) : The prefix “@” enables the use of keywords as identifiers, which is useful when interfacing with other programming languages. The character @ is not actually part of the identifier, so the identifier might be seen in other languages as a normal identifier, without the prefix. An … Read more

How to encode the filename parameter of Content-Disposition header in HTTP?

I know this is an old post but it is still very relevant. I have found that modern browsers support rfc5987, which allows utf-8 encoding, percentage encoded (url-encoded). Then Naïve file.txt becomes: Content-Disposition: attachment; filename*=UTF-8”Na%C3%AFve%20file.txt Safari (5) does not support this. Instead you should use the Safari standard of writing the file name directly in … Read more

tech