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
96b25e1c
Commit
96b25e1c
authored
Oct 24, 2019
by
MohammadAli Keshavarz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
this key word
parent
9914d384
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
1 deletion
+32
-1
script.js
section2/script.js
+32
-1
No files found.
section2/script.js
View file @
96b25e1c
...
...
@@ -18,7 +18,7 @@ var x=23
/////////////////////////////////////
// Lecture: Scoping
/*
// First scoping example
var a = 'Hello!';
first();
...
...
@@ -46,5 +46,36 @@ function third() {
//console.log(c);
console.log(a+d);
}
*/
/////////////////////////////////////
// Lecture: The this keyword
//console.log(this);
calculateAge
(
1985
);
function
calculateAge
(
year
)
{
console
.
log
(
2016
-
year
);
console
.
log
(
this
);
}
var
john
=
{
name
:
'John'
,
yearOfBirth
:
1990
,
calculateAge
:
function
()
{
console
.
log
(
this
);
console
.
log
(
2016
-
this
.
yearOfBirth
);
function
innerFunction
()
{
console
.
log
(
this
);
}
innerFunction
();
}
}
john
.
calculateAge
();
var
mike
=
{
name
:
'Mike'
,
yearOfBirth
:
1984
};
mike
.
calculateAge
=
john
.
calculateAge
;
mike
.
calculateAge
();
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