Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
Learning JavaScript
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MohammadAli Keshavarz
Learning JavaScript
Commits
9914d384
Commit
9914d384
authored
Oct 24, 2019
by
MohammadAli Keshavarz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Scoping
parent
77f015ee
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
0 deletions
+37
-0
script.js
section2/script.js
+37
-0
No files found.
section2/script.js
View file @
9914d384
/////////////////////////////////////
// Lecture: Hoisting
/*
calculateAge(1988);
calculateAge(1988);
function calculateAge(year){
function calculateAge(year){
...
@@ -9,5 +12,39 @@ var calculateAge2 = function(year){
...
@@ -9,5 +12,39 @@ var calculateAge2 = function(year){
calculateAge2(1988)
calculateAge2(1988)
console.log(x);
console.log(x);
var x=23
var x=23
*/
/////////////////////////////////////
// Lecture: Scoping
// First scoping example
var
a
=
'Hello!'
;
first
();
function
first
()
{
var
b
=
'Hi!'
;
second
();
function
second
()
{
var
c
=
'Hey!'
;
console
.
log
(
a
+
b
+
c
);
}
}
// Example to show the differece between execution stack and scope chain
var
a
=
'Hello!'
;
first
();
function
first
()
{
var
b
=
'Hi!'
;
second
();
function
second
()
{
var
c
=
'Hey!'
;
third
()
}
}
function
third
()
{
var
d
=
'John'
;
//console.log(c);
console
.
log
(
a
+
d
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment