Sorry for the stupid question.
Browsing through different JS-scripts I see that locally used variables are sometimes declared with var and sometimes with let, and myself I seem to have used them quite interchangeably. However, I seem to recall Ahruman explaining that one of them is not good and discouraged for some reason. But which?
EDIT: And while I am posting this, Safari quits unexpectedly and violently. Oops? Have I pissed off the invisible powers of programming???
JS: var vs. let?
Moderators: winston, another_commander
- Commander McLane
- ---- E L I T E ----
- Posts: 9520
- Joined: Thu Dec 14, 2006 9:08 am
- Location: a Hacker Outpost in a moderately remote area
- Contact:
- Commander McLane
- ---- E L I T E ----
- Posts: 9520
- Joined: Thu Dec 14, 2006 9:08 am
- Location: a Hacker Outpost in a moderately remote area
- Contact:
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
let is added to the is vocabulary in a later JS version. It wasn't always there. In most cases both are interchangeable. let is a bit more local valid. You can redefine a value within a loop with a let statement and it starts using the old value after the loop. But in this way we never use it.
When you look inside the widgets on a mac you see that they are also programmed in JS (At least a large part of them). There you only see the use of var. let is never used and according to Ahruman its use could change or end in future.
When you look inside the widgets on a mac you see that they are also programmed in JS (At least a large part of them). There you only see the use of var. let is never used and according to Ahruman its use could change or end in future.
UPS-Courier & DeepSpacePirates & others at the box and some older versions
- Commander McLane
- ---- E L I T E ----
- Posts: 9520
- Joined: Thu Dec 14, 2006 9:08 am
- Location: a Hacker Outpost in a moderately remote area
- Contact: