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
afd9ae29
Commit
afd9ae29
authored
Oct 10, 2019
by
MohammadAli Keshavarz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Operator precedence
parent
61f3bb77
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
2 deletions
+32
-2
script.js
script.js
+32
-2
No files found.
script.js
View file @
afd9ae29
...
@@ -44,7 +44,7 @@ console.log(firstName + ' ' + lastName);
...
@@ -44,7 +44,7 @@ console.log(firstName + ' ' + lastName);
/*****************************
/*****************************
* Basic operators
* Basic operators
*/
*/
/*
var year, yearJohn, yearMark;
var year, yearJohn, yearMark;
now = 2018;
now = 2018;
ageJohn = 28;
ageJohn = 28;
...
@@ -64,4 +64,34 @@ console.log(typeof johnOlder);
...
@@ -64,4 +64,34 @@ console.log(typeof johnOlder);
console.log(typeof ageJohn);
console.log(typeof ageJohn);
console.log(typeof 'Mark is older tha John');
console.log(typeof 'Mark is older tha John');
var x;
var x;
console
.
log
(
typeof
x
);
console.log(typeof x);
\ No newline at end of file
*/
/*****************************
* Operator precedence
*/
var
now
=
2018
;
var
yearJohn
=
1989
;
var
fullAge
=
18
;
// Multiple operators
var
isFullAge
=
now
-
yearJohn
>=
fullAge
;
// true
console
.
log
(
isFullAge
);
// Grouping
var
ageJohn
=
now
-
yearJohn
;
var
ageMark
=
35
;
var
average
=
(
ageJohn
+
ageMark
)
/
2
;
console
.
log
(
average
);
// Multiple assignments
var
x
,
y
;
x
=
y
=
(
3
+
5
)
*
4
-
6
;
// 8 * 4 - 6 // 32 - 6 // 26
console
.
log
(
x
,
y
);
// More operators
x
*=
2
;
console
.
log
(
x
);
x
+=
10
;
console
.
log
(
x
);
x
--
;
console
.
log
(
x
);
\ No newline at end of file
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