Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for(let i = 0; i < 1; i++) {
- alert(i);
- }
- alert(i);
- for(var i = 0; i < 1; i++) {
- alert(i);
- }
- alert(i);
- //# sourceMappingURL=test.js.map
- "scripts": {
- "start": "tsc && concurrently "npm run tsc:w" "npm run lite" ",
- "lite": "lite-server",
- "postinstall": "typings install",
- "tsc": "tsc",
- "tsc:w": "tsc -w",
- "typings": "typings"
- },
- for(let i = 0; i < 1; i++) {
- alert(i);
- }
- alert(i); // compile error: cannot find name 'i'
- for (let i = 0; i < 3; i++) {
- setTimeout(function() { alert(i); });
- }
- function theDifference(){
- for(let emre = 0; emre < 10; emre++){
- // emre is only visible inside of this for()
- }
- // emre is NOT visible here.
- }
- function theDifference(){
- for(var emre = 0; emre < 10; emre++){
- // emre is visible inside of this for()
- }
- // emre is visible here too.
- }
- console.log('not defined = ' + notDefinedIsLegal);
- var notDefinedIsLegal;
- console.log('mustBeDefined = '+ mustBeDefinedBeforeUse);
- let mustBeDefinedBeforeUse = 'Hello World';
- console.log('not defined = ' + notDefinedIsLegal);
- var notDefinedIsLegal : string;
- let mustBeDefinedBeforeUse = 'Hello World';
- console.log('mustBeDefined = '+ mustBeDefinedBeforeUse);
- {
- var notDefinedIsLegal = "legal!";
- let mustBeDefinedBeforeUse = "Goodbye World!!";
- console.log('[blockscoped] mustBeDefined = '+ mustBeDefinedBeforeUse);
- console.log('[blockscoped] notDefinedIsLegal = ' + notDefinedIsLegal);
- }
- console.log('mustBeDefined = '+ mustBeDefinedBeforeUse);
- console.log('notDefinedIsLegal = '+ notDefinedIsLegal);
- not defined = undefined
- mustBeDefined = Hello World
- [blockscoped] mustBeDefined = Goodbye World!!
- [blockscoped] notDefinedIsLegal = legal!
- mustBeDefined = Hello World
- notDefinedIsLegal = legal!
Add Comment
Please, Sign In to add comment