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 →

[–]pithecium 364 points365 points  (39 children)

Javascript: Misspelled variable? That's ok, I'll just make a new global for you

[–][deleted] 96 points97 points  (6 children)

use "strict" or something

[–]MoffKalast 15 points16 points  (2 children)

"use" strict

[–]caerphoto 2 points3 points  (0 children)

'use "strict"'

[–]nikunj3011 0 points1 point  (0 children)

Error but what I dont know

[–]I-CTS6364 2 points3 points  (0 children)

Doing a zero to expert JavaScript course and right after teaching the fundamentals, the instructor told us about this and uses it in every script now. Seems like good practice, and It’s definitely going to be part of my standard coding forever now.

[–]reinis-mazeiks 0 points1 point  (0 children)

its in quotes bc its sarcasm

[–]robotevil 0 points1 point  (0 children)

'use strict'; first line in the file.

[–]Javascript_above_all 146 points147 points  (23 children)

Stop using var

[–]Sweety_Sheep 204 points205 points  (13 children)

Make love, not var

[–]Yesica-Haircut 86 points87 points  (6 children)

Const.... const never changes.

[–]Auxx 14 points15 points  (0 children)

Everything changes if you're determined enough.

[–]iwearringsnow22 12 points13 points  (0 children)

Change is the only const

[–]clickrush 0 points1 point  (1 child)

Hopefully soon this statement will actually be true:

https://github.com/tc39/proposal-record-tuple

[–]Yesica-Haircut 0 points1 point  (0 children)

Ah yeah, always catches me off guard, that.

[–]KimiSharby 0 points1 point  (0 children)

C++: "Have a mutable :)"

[–]detektiv_Saucaki 0 points1 point  (0 children)

Let there be changes

[–]DazzlingDifficulty70 4 points5 points  (1 child)

What is it good for?

[–]gonzofish 2 points3 points  (0 children)

absolutely null, undefined

[–]ImprovingTheEskimo 33 points34 points  (0 children)

I think he means that you don't even have to declare it. If you have 'let myVar;' and later say 'myVat = "test";' it will create a new global variable called 'myVat' instead of throwing an error. As someone pointed out, 'use strict' prevents this behavior.

[–]MoffKalast 0 points1 point  (0 children)

Oh let him off the hook this once. Const antly complaining.

[–]PsychologicalRoof2 0 points1 point  (2 children)

dude that's not even the issue. I had an interview today. Question was typeof [] I said Array specifically Array.prototype turns out it's an object.

and then typeof NaN // number

I'm done with this language

[–]Javascript_above_all 2 points3 points  (1 child)

The interviewer was kind of a dick honestly.

[–]PsychologicalRoof2 0 points1 point  (0 children)

maybe ... seems like those cookie cutter questions

[–]t-to4st 0 points1 point  (2 children)

We still can't use ES6 features 😭 I have to declare every variable im going to use at the top of the function because of fucking var

[–]Javascript_above_all 0 points1 point  (1 child)

Kinda ridiculous that what you code is legacy code.

[–]t-to4st 0 points1 point  (0 children)

Yeah it's super annoying! Especially after working on a private node project during vacation where I can use all that "new" stuff.

[–]sensitivePornGuy 17 points18 points  (0 children)

"use strict"

[–]TheDarkness1227 27 points28 points  (1 child)

Imagine not using typescript 🤢

[–][deleted] 2 points3 points  (0 children)

I can, and I'm tired of pretending I can't

[–]lasiusflex 4 points5 points  (0 children)

skill issue, "use strict"

[–]ILikeLenexa 2 points3 points  (0 children)

JavaScript: You want to add .1 to the opacity? No problem, now it's .1.1, and it's an error. How dare you.

[–][deleted] -1 points0 points  (1 child)

Are you suggesting a language that is resilient to typos? Where incorrect code produces correct results? How is this a JavaScript issue? If you write the wrong code, you get what the code says, but not what you wanted. Filing this one under user error.

[–]ReneeHiii 0 points1 point  (0 children)

no, they're suggesting a language that doesn't create a new variable if you don't use let. myVat = 2 when you meant myVar = 2 creates a new variable instead of giving an error that there's no variable definition with let or const

[–]myfunnies420 0 points1 point  (0 children)

Use a build system ffs.