Operators
The most common JavaScript operators can be put into the following categories:
Arithmetic Operators
Assignment Operators
Comparison Operators
Logical Operators
Arithmetic Operators
Assignment Operators
Comparison Operators
Logical Operators
Recommendations
Explore
Mirth® Connect by NextGen Healthcare User Guide
Logical Operators
Logical operators are used to determine the logic between variables or values. In this table, the x-variable has a value of 6, and the y-variable has a value of 3 to explain the JavaScript Logical operators: Operator Description Example && and (x < 10 && y > 1) is true || or (x==5 || y==5) is false ! not !(x==y) is true Parent topic: Operators
Mirth® Connect by NextGen Healthcare User Guide
Comparison Operators
Comparison operators are used in logical statements to determine equality or difference between variables or values. In this table, the x-variable has a value of 5 to explain the JavaScript Comparison operators: Operator Description Comparing Returns == is equal to x==8 false x==5 true != is not equal to x!=8 true > is greater than x>8 false < is less than x<8 true >= is greater than or equal to x>=8 false <= is less than or equal to x<=8 true Parent topic: Operators
Mirth® Connect by NextGen Healthcare User Guide
Assignment Operators
These operators are used to assign values to JavaScript variables. In this table, the x-variable has a value of 10, and the y-variable has a value of 5 to explain the JavaScript Assignment operators: Operator Description Example Same As Result = assign x=y x=y (5) x=5 += add and assign x+=y x=x+y (10+5) x=15 -= subtract and assign x-=y x=x-y (10-5) x=5 *= multiply and assign x*=y x=x*y (10*5) x=50 /= divide and assign x/=y x=x/y (10/5) x=2 %= modulus (division remainder) and assign x%=y x=x%y (remainder is 0 for the equation 10/2) x=0 Parent topic: Operators
Mirth® Connect by NextGen Healthcare User Guide
Arithmetic Operators
These operators are used to perform arithmetic between variables and/or values. In this table, the y-variable has a value of 5 to explain the JavaScript Arithmetic operators: Operator Description Example Result of x Result of y + Addition x=y+2 (5+2) 7 5 - Subtraction x=y-2 (5-2) 3 5 * Multiplication x=y*2 (5*2) 10 5 / Division x=y/2 (5/2) 2.5 5 % Modulus (division remainder) x=y%2 (remainder is 1 for the equation 5/2) 1 5 ++ Increment x=++y (++6) 6 (a) 6 (b) x=y++ (6++) 5 (c) 6 (b) -- Decrement x=--y (--4) 4 (d) 4 (e) x=y-- (4--) 5 (f) 4 (e) (a) The increment occurs before the variable, so x is the incremented value of y, which is 6; (b) The value is 6 because y, which is 5, is increased by 1 for this operator; (c) The increment occurs after the variable, so x is the original value of y, which is 5; (d) The decrement occurs before the variable, so x is the decremented value of y, which is 4; (e) The value is 4 because y, which is 5, is decreased by 1 for this operator; (f) The decreme
Mirth® Connect by NextGen Healthcare User Guide
Conditional Statements
This example shows the basic syntax structure for conditional statements in JavaScript: if (condition1) { // Code to execute} else if (condition2) { // Code to execute} else { // Code to execute} Parent topic: About JavaScript
Mirth® Connect by NextGen Healthcare User Guide
Loops and Iterations
A loop is a type of programming-language statement that lets code be executed repeatedly; that is, a loop is a series of iterations. In programming language, there are four types of loops: for loops for each…in loops while loops do…while loops An iteration is a single execution of the inner loop process. If you loop from 1 to 10, the code inside the loop will be executed for 10 iterations. Loops can be unconditionally exited with a break statement: break;. The continue statement: continue; unconditionally skips to the next iteration of the loop. for loops for each…in loops while loops do…while loops Parent topic: About JavaScript