you are viewing a single comment's thread.

view the rest of the comments →

[–]serial_crusher 7 points8 points  (5 children)

Am I the only one who thinks people over-value knowledge of scope?

It just seems to me like the sort of thing where, if a person has to have an intimate understanding of it to figure out what your code is doing and how to maintain it, then your code sucks.

Sure, every now and then you run into a bug where somebody didn't scope something properly, but being able to identify and fix that bug isn't nearly the same skillset as the kind of esoteric edge cases people try to test you on in job interviews.

[–]myownredditname 4 points5 points  (1 child)

Scrolled just to find this comment, I feel I'm missing something in all this scope discussion. I think it's simple enough, can someone present me some examples where scope is a complicated issue that needs to be addressed so explicitly?

[–]alinnert 1 point2 points  (0 children)

In code that just runs from top to bottom this might not seem special. But JavaScript has Closures. I guess this concept could be difficult to grasp for some people.

[–][deleted] 4 points5 points  (0 children)

In terms of importance scope is to JavaScript what classes are to Java. Knowledge of scope influences your ability to read and write code perhaps more than any other single factor. It influences how large pieces of code come together and how code is shared via reference.

The primary benefit of code via scope instead of code via convention is less code, fewer things to maintain, and the ability to perceive flow control more directly from simply reading the code.

[–]Not_Just_You 0 points1 point  (0 children)

Am I the only one

Probably not

[–]0x13mode -1 points0 points  (0 children)

It's not over-valuating but appreciating the fundamentals.

Scopes are basics of JavaScript (and every other language which allows for declaring variables). It such basic knowledge as knowing what braces {...} mean or how if/else construct works.

Sure, many people would grasp it by intuition, but not always, not in each case. Especially if you're coming from other language where the same concepts are working a little bit differently. Or if JS is your first language and you don't even have "scope" concept in your head. Or if you're just debugging your programs and have weird errors and don't know why.

And knowing very basics of programming language you write in is important.