Comments (4)
Your second example is not even really that safe in terms of scope.
In JavaScript (before 1.7), there is no such thing as block scope. Declaring a variable in a for
loop with var
will use the scope of its parent function or, in the absence any such containing function, the global scope.
JavaScript 1.7 introduced the let
keyword for block scope to be used instead of var
. Being a feature of JavaScript 1.7, the let
keyword is not ready for general web use as of this time due to lack of support by some browsers, most notably IE.
from front-end-development-guidelines.
The second example throws a JavaScript error, even if I "use strict";
from front-end-development-guidelines.
Well, I feel stupid. Goes to show you should actually test bug reports before submitting them.
from front-end-development-guidelines.
For clarity: http://jsfiddle.net/WuK5w/
from front-end-development-guidelines.
Related Issues (20)
- Add Section: Commenting CSS Blocks HOT 1
- Change "ambiguous" to "redundant" HOT 1
- Site Needs to be Accessible without JavaScript Enabled
- Some tips HOT 3
- Caching Selector Results section code example HOT 2
- W3C markup validation HOT 6
- Some people are very fond of their C style strings (single quotes)... HOT 1
- Queue - a profoundly British word HOT 1
- css shorthand, camelCasing and POSH HOT 3
- parseInt is not octal/binary by default HOT 2
- Isn't it spelled "Degradation"? With an "a"? HOT 1
- CamelCase in JS variables HOT 1
- width:auto does work HOT 2
- Add Section - Creating Unique IDs without Timestamps
- Add Section - When to Float, When to Position
- Add Section - Understanding the Box Model
- Strings: single vs double quotes HOT 1
- Pagespeed & Loadtimes
- Accessibility alt text HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from front-end-development-guidelines.