Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
LuxARTS16636y@dextel2 'let' is a reserved keyword so you can't use it as a variable name. It's a bug from interpreter if you don't get an error. It's like write: int char = 1; in C/C++.
-
LuxARTS16636y@dextel2 I think the interpreter that you are using has a bug.
Google "let JavaScript" to get details about it. -
Meta33866yDon't complain about programming languages if your attempts to learn that language is garbage input.
Might aswell override false with true and complain again. -
To people who actually understand JavaScript, this is probably like typing *&_()#-djks and blaming the language for throwing an error.
Everything in the screenshot is expected behaviour -
@dextel2 It's not possible to eli5 a concept as complex as this.
1) First off, check this list of reserved words you shouldn't use as variable names. http://javascripter.net/faq/...
Both let and var are legal identifiers and should not be used.
let var
var let
Both are wrong.
2) The difference between let and var is that let is block scoped. It doesn't exist outside the function it's declared in. So let var throws an error, because it tries to create a distinct variable of name "var"
var can be global scoped and binds to the window object. window is the global root object.
"var let =1" done globally
is just shorthand for
"window.let = 1"
Since window.let as a whole isn't exactly a legal identifier, there isn't an error, but that doesn't make it right.
3) I would really recommend you to follow a good standard tutorial or previously written application, if you're looking at learning. Playing around with garbage inputs won't be much productive, because JS being dynamically typed, does a lot of internal work to set variable types. This leads to some non intuitive behavioral, which will take some time to get used to. This is true of all dynamic typed languages, especially one like JS which is sort of a mix of two versions (es5 and es6) in one package.
Guess I'll never understand javascript, same behavior with const
joke/meme
is this life
javascript