, , , , , .
: , EMCAScript 3. var . var let , , , , var . . 1999 !
, . , :
(function () {
console.log(somethingUndefined - 1);
var somethingUndefined;
console.log('another operation');
})();
Hide result, . ?
(function () {
try {
console.log(somethingUndefined - 1);
var somethingUndefined = 50;
console.log('another operation');
} catch (e) {
console.log('I want to deal with problems here');
return;
}
console.log('plowing on');
})();
Hide result.
:
(function () {
var somethingUndefined = undefined;
try {
console.log(somethingUndefined - 1);
somethingUndefined = 50;
console.log('another operation');
} catch (e) {
console.log('I want to deal with problems here');
return;
}
console.log('plowing on');
})();
Hide result" ", B C , somethingUndefined -. "undefined", somethingUndefined === undefined, . 50, , . , , -, . 1, 8, . :
(function () {
try {
console.log(somethingUndeclared - 1);
console.log('another operation');
} catch (e) {
console.log('I want to deal with problems here');
console.log(e);
}
})();
Hide resultD somethingUndeclared . . , EMCAScript , , .
- somethingUndeclared, , . , , var somethingUndeclared; - - , anoy . let const .
let const, " ", , -, -. undefined, . let, , , var . var .
(function () {
try {
console.log(something - 1);
let something = 50;
console.log('another operation');
} catch (e) {
console.log('I want to deal with problems here');
console.log(e);
}
})();
Hide result: " , ?" , , , . javascript, , UI. , EMCAScript . . , , , . , , ('99).
When we need this to do what he needs to do all the time, we can use these functions. When it would be a disaster undefined = 100;to be in some kind of file in the project, we can refuse exceptions. When a progressive improvement fails and we don't get any tooltips, we have a less good UX than we hoped. var and let them have different stories and different weights on their shoulders, so they are likely to always act differently.