4 ms·
This is still weird. Use variables. Not this. ";" is still auto inserted. If you insert the semicolons yourself and don't depend on the auto insertions,
by z3t4 9y ago
This is still weird.
Use variables. Not this.
";" is still auto inserted.
If you insert the semicolons yourself and don't depend on the auto insertions, you don't have to worry about the edge cases where the lack of a semicolon would introduce a bug.
"==" still compares like nothing else.
Use === if you want to be explicit.
Errors come in different so many different forms it's not funny.
I agree, but this is only a problem with new API's like service workers, what where they (TC39) thinking when introducing unspecified errors !? That can't even be detected !! There's already a convention to use err.code to specify type of error, use that please!
Basic maths assumptions like commutativity are out of scope.
The commutativity is the same like in classic Maths I think, it's just he floating point errors that mess things up.
Still no namespaces, but instead we use monstrosity like webpack and incompatible import systems to encapsulate things.
The module system (require) in Node.JS comes from user-land, and can be implemented in pure JavaScript, so you can use it in the browser too!
Stdlib still doesn't have essential things like hashing, string/date formatting or encoding.
We have .toString, parseInt, atob, btoa, etc. The rest can be implemented in user-land: var md5 = require("md5")
Even basic operation like removing an element from an array using an index is a pain.
I think it's fine. If you use a named list {} you can "delete foo[bar]"
- sametmax 9y ago> Use variables. Not this. You can't if you use react. Besides, JS is the only language I know where half of it is recommended to not be used. > If you insert the semicolons yourself and don't depend on the auto insertions, you don't have to worry about the edge cases where the lack of a semicolon would introduce a bug. But that's not the point. The point is my students will forget the semicolon in some code that is not properly checked, and it will work. Most of the time. Until it doesn't. > Use === if you want to be explicit. No shit sherlock ? But again, half of the language is forbidden. And you know somebody is going to write != instead of !== one day, tired. > The commutativity is the same like in classic Maths I think, it's just he floating point errors that mess things up. Nope. Nope. Nope. Nope. $ node > [] + {} '[object Object]' > {} + [] 0 > We have .toString, parseInt, atob, btoa, etc. Come on, you never used Java, Perl, Ruby, Python? Any language with decent string formatting ? That doesn't need a leftpad dependancy ? That can format date without importing 34ko of moment.js ? > The rest can be implemented in user-land: var md5 = require("md5") And then you get the current 3Mo pages we all hate. Are you even serious with your arguments or is it trolling ? > I think it's fine. If you use a named list {} you can "delete foo[bar]" A mapping is not a list. It doesn't perform the same. You can't push and unshift. You can map on it without Object.stuff. Length is a costly operation. Concat without spread is a pain. And how do you get the "next 3 elements after the 2nd" ?
- simplicitea 9y ago> And how do you get the "next 3 elements after the 2nd" ? .splice(2, 3) (am I missing something?) > > The rest can be implemented in user-land: var md5 = require("md5") And then you get the current 3Mo pages we all hate. Are you even serious with your arguments or is it trolling ? md5 node lib is 32kb unbundled. If you meant 3Mb pages that's ridiculous. Modular necessity at the hands of the user is good, and it's something that's been present in every project i've worked on in a less granular fashion than modern npm-driven apps can deliver.
- sametmax 9y agoOP was talking about trading [] for {}. You can't splice on {}.
- simplicitea 9y agowell, objects are not iterables... ??? unless you decide you want them to be, in which case you can make them such and design them in a way that they work as such? The least elegant way is Object.keys().map(key => etc) which is really not that hard to work with edit: it's a phony premise to begin with actually. Iterables have order, objects have mapping. I am less experienced with other languages so I probably don't understand OP's statement clearly. I just think OP's context is lazy thought rot about what's becoming a fairly elegant language. BUT I'm a noob.
- z3t4 9y ago> Besides, JS is the only language I know where half of it is recommended to not be used. That's what you get for having backward compatibility I guess. If the standards committee would break my old code I would probably quit and start a sect. I would call it "ReactReduxReduce" (RRR). > The point is my students will forget the semicolon in some code that is not properly checked, and it will work. Most of the time. Until it doesn't. Some people prefer writing JavaScript without semicolons. How do they not have bugs all over the place ? :P
- 9y ago
- tedunangst 9y ago> If you insert the semicolons yourself and don't depend on the auto insertions, you don't have to worry about the edge cases where the lack of a semicolon would introduce a bug. I think this is not correct. It will still insert a semicolon where you don't want one. It's not like there's a compiler flag to turn insertion off.
- cerved 9y agoThat's not how it works, semicolons are only automatically inserted if they were omitted. Use semicolons, lint the code, ????, profit
- z3t4 9y agoI just tried to get the linter (JShint) to break some valid code, but it didn't. So you can actually rely on the linter to insert the semicolons for you. It would be interesting to find out if there are any cases where the linter will insert the semicolon in the wrong place.
- tedunangst 9y agoThe browser somehow detects that the missing semicolon wasn't omitted and doesn't add it???
- cerved 9y agoNo. If it's missing it's inserted obviously. That's why you shouldn't omit it. Here are the rules for parsing if you're interested When the program contains a token that is not allowed by the formal grammar, then a semicolon is inserted if (a) there is a line break at that point, or (b) the unexpected token was a closing brace. When the end of a file is reached, if the program cannot be parsed otherwise, then a semicolon is inserted. When a "restricted production" is encountered and contains a line terminator in a place where the grammar contains the annotation "[no LineTerminator here]", then a semicolon is inserted.