Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
VMware vRealize Orchestrator Essentials

You're reading from   VMware vRealize Orchestrator Essentials Get hands-on experience with vRealize Orchestrator and automate your VMware environment

Arrow left icon
Product type Paperback
Published in Sep 2015
Publisher
ISBN-13 9781785884245
Length 184 pages
Edition 1st Edition
Arrow right icon
Author (1):
Arrow left icon
Daniel Langenhan Daniel Langenhan
Author Profile Icon Daniel Langenhan
Daniel Langenhan
Arrow right icon
View More author details
Toc

The if-clause in JavaScript


The if-clause is equivalent to the Decision element that we used in the last chapter. It checks whether a condition has been met.

The JavaScript code for an if statement isn't that difficult. It is made up of a condition and the if-clause itself. The form looks like this:

Statement

Example

if (condition) {
    code block
} else if (condition) {
    code block
} else {
    code block
}
if (varString == "test") {
    varResult=true;
} else {
    varResult=false;
}

In the preceding example, the varString string is tested if it contains the word "test". If it does, the Boolean varResult is set to true. If it is not (the else part), it is set to false. The else if block can be added multiple times.

Conditions and operators

A condition is made up of a statement that is either true or false. This statement is built by using operators. The following are the operators that JavaScript knows:

and

or

Not

Equal

Not equal

Smaller

Bigger

&&

||

!

==

!=

&lt...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image