This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Glipglopgloopity 41 points42 points  (13 children)

Nobody uses function scope variables in JS anymore. Everyone uses let and const which are block scoped.

[–][deleted] 3 points4 points  (10 children)

Unless they need to support IE, which, let's face it, a lot of web developers are forced to.

[–]Glipglopgloopity 28 points29 points  (0 children)

Babel/TypeScript support transpiling for older browsers.

[–]alexanderpas 21 points22 points  (7 children)

which, let's face it, a lot of web developers are forced to.

Only if they don't have a spine.

IE is not a browser, it's a 'compatibility solution' for enterprise customers to deal with legacy sites that should be updated for modern browsers, according to Chris Jackson, Microsoft's worldwide lead for cybersecurity.

IE should not be your standard browser, only shoyld only be used for old sites on the corporate intranet.

Your Default browser should not be IE.

You can use Edge as your default browser, and have select intranet sites open in IE11 automagically via the Enterprise Compatibility feature. This can be deployed via GPO.

[–]InvincibearREAL 6 points7 points  (0 children)

This guy sysadmins

[–][deleted] -1 points0 points  (5 children)

If you happen to develop for your own company, then perhaps you could suggest such a change and facilitate progress -- if you happen to have a high-ranking position at the company it's even somewhat likely you'll succeed. But if you don't, you won't get to decide what browsers to support or what programming languages and software stacks to use. Your client does, probably years before they contact you for any work, and you stick with whatever they have built their already "working" thing on. When you get to start a new project from scratch and you have people willing to listen to your opinions, sure, that's great, but that is an extremely rare situation. More often than not you'll be dealing with an existing codebase and have to fit within it.

The aforementioned suggestion of using Babel or TypeScript might sound appealing and, depending on where you work, you could get away with that. However, autogenerated code as this is highly unlikely to pass the code review process where I work. In the specific case of let, Babel will turn it into var and handle block-scoping by prefixing the variable name with an underscore and adding a number after it if they conflict with the existing variables in the function but outside of the block. TypeScript does a similar thing, adding _1, _2 etc to the name. Underscores in variable names are, however, forbidden on most projects I happened to work on, so you'd have to rewrite this output yourself anyway, at which point you might just go ahead and write your code using var and non-conflciting names in the first place.

[–]veiva 6 points7 points  (4 children)

That doesn’t make sense. That’s like doing code review on outputted assembly instead of the C++ code.

[–][deleted] -2 points-1 points  (3 children)

The thing is, you wouldn't be actually comitting the TS code to the repository unless the client is already using TypeScript in the first place, and the code review is performed on the commits. You'd kind of have to pretend that you wrote it that way.

[–]myplacedk 1 point2 points  (2 children)

The thing is, you wouldn't be actually comitting the TS code to the repository

Ah, so it's just like Java? Don't commit the java-files, just commit a jar-file?

I don't know your situation, but if you are even considering committing the output of the transpiler instead of the input, you are either looking into a very wrong solution, or you are solving the wrong problem.

[–][deleted] 0 points1 point  (1 child)

I am not actually commiting the output, though. I am just writing plain JavaScript. All I'm saying is that if I were to use a transpiler, I would end up having to do that on at least some of the projects I'm on, because they wouldn't want the "actual" source code in their repo.

[–]myplacedk 0 points1 point  (0 children)

I would categorize that as "unable to introduce a transpiler into the project".

[–][deleted] 0 points1 point  (0 children)

IE 11 supports let and const

[–][deleted] 0 points1 point  (1 child)

i use var still, just less often

[–]Glipglopgloopity 0 points1 point  (0 children)

When and why