Learn how these common, shorter (less readable) ways of phrasing if statements work.
- [Instructor] In this video we're going to look at a few…of the forms in which if statements will be made shorter.…You may write these in your own code,…and you will certainly see them if you start looking…at other people's JavaScript code.…First, the one liner.…So I'm setting a variable up here, for a cherub,…who is going to start out as Cupid.…I have a comment for making the cherub Some Other Guy.…So first we're going to copy these first few lines…and bring them over to the browser.…You'll notice that I've put this if statement entirely…on one line with no curly braces, and it will still work.…
There, so I executed it, and the cherub is Cupid,…so having checked that, I still log this message…to the console, even though there's no curly braces.…Likewise, I can include an else block on the next line,…again with no curly braces, and it'll still work.…Let's paste this in.…We know the cherub is still cupid.…So, I'm still getting the same message,…but if I change the cherub to some other guy,…and then I execute this line again,…
Author
Released
2/5/2019- Using a text editor
- Declaring and assigning variables
- Booleans and the quest for truth
- Working with objects and arrays
- Using operators and control structures
- Iterating with loops
- Objects, references, and functions
- Promises, async, and await
Skill Level Beginner
Duration
Views
Related Courses
-
JavaScript for Web Designers
with Joe Chellman2h 43m Beginner -
Learning App Building with Vanilla JavaScript
with Sasha Vodnik1h 44m Intermediate
-
Introduction
-
1. Getting Started
-
Versions of JavaScript1m 43s
-
Additional helpful resources2m 25s
-
2. Variables and Types
-
3. Objects, Arrays, and More
-
Objects3m 21s
-
Objects for modeling data2m 20s
-
Manipulating objects3m 52s
-
Arrays4m 55s
-
Manipulating arrays5m 43s
-
Readability: Whitespace2m 35s
-
Readability: Comments4m 7s
-
Regular expressions5m 43s
-
-
4. Operators and Control Structures
-
Simple comparisons4m 10s
-
Arithmetic operators5m 24s
-
Logical operators5m 43s
-
Conditionals: If6m 21s
-
Conditionals: Switch3m 53s
-
Terse ifs4m 59s
-
Ternary operator2m 30s
-
Type checking5m 30s
-
-
5. Iterating with Loops
-
For loops: Sequential6m 9s
-
For loops: Enumerative4m 33s
-
While loops5m 36s
-
-
6. Functions
-
Basic functions2m 40s
-
Arguments in functions4m 23s
-
More on arguments5m 45s
-
Functions are objects4m 18s
-
Jargon: Scope in JavaScript1m 55s
-
Variable scope in functions3m 20s
-
Jargon: Callback functions3m 31s
-
-
7. More Advanced Pieces
-
Promises, async, and await3m 26s
-
Modern JavaScript tooling3m 21s
-
Conclusion
-
Next steps3m 38s
-
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.
CancelTake notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.
Share this video
Embed this video
Video: Terse ifs