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
adb38bb1
Commit
adb38bb1
authored
Oct 10, 2019
by
MohammadAli Keshavarz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Truthy and Falsy values and equality operators
parent
dd9c9926
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
1 deletion
+18
-1
script.js
script.js
+18
-1
No files found.
script.js
View file @
adb38bb1
...
@@ -153,7 +153,7 @@ if (age < 13) {
...
@@ -153,7 +153,7 @@ if (age < 13) {
/*****************************
/*****************************
* The Ternary Operator and Switch Statements
* The Ternary Operator and Switch Statements
*/
*/
/*
var firstName = 'John';
var firstName = 'John';
var age = 14;
var age = 14;
// Ternary operator
// Ternary operator
...
@@ -197,4 +197,21 @@ switch (true) {
...
@@ -197,4 +197,21 @@ switch (true) {
}
}
/*****************************
* Truthy and Falsy values and equality operators
*/
// falsy values: undefined, null, 0, '', NaN
// truthy values: NOT falsy values
var
height
;
height
=
23
;
if
(
height
||
height
===
0
)
{
console
.
log
(
'Variable is defined'
);
}
else
{
console
.
log
(
'Variable has NOT been defined'
);
}
// Equality operators
if
(
height
===
'23'
)
{
console
.
log
(
'The == operator does type coercion!'
);
}
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