JavaScript – Logical Operators
Logical operators are used to determine the logic between variables or values.
Logical operators are used to determine the logic between variables or values.
The ternary (conditional) operator assigns a value to a variable based on a condition.
The break statement stops code execution within the switch, and also breaks out of a loop, continuing to execute code that comes after the loop.
The continue statement breaks an iteration in the loop, if a specified condition occurs, and then continues with the next iteration in the loop.
The do…while statement defines a code block to be executed at least once, and repeated as long as a condition is true.
The for statement defines a block of code to be executed as long as a specified condition is true.
The for…in statement loops over the properties of an object, executing a block of code inside the loop once for each item found.
The for…of statement loops over the values of any iterable, executing a block of code inside the loop once for each item found.
The if…else statement executes a block of code if a specified condition is true, and optionally, another block of code if false.
The switch statement executes different blocks of code depending on set conditions, and uses the break keyword to break out of the switch block.
The while statement defines a code block to be executed for as long as a condition is true.
This is a quick reference list of JavaScript statements with examples of how they are used.
The PHP and keyword is a logical operator and is used to combine conditional statements.
The PHP case keyword is used to jump to a line of code when an expression has a specific value in a switch conditional.
The PHP default keyword is used in a switch block to specify which code to run when none of the case statements were matched by the expression.
The PHP else keyword specifies a block of code which should run when the condition of an if statement is not met.
The PHP elseif keyword tests a new condition if the condition of a previous if or elseif statement was not met.
The PHP endif keyword is used to mark the end of an if conditional which was started with the if, or elseif syntax.
The PHP endswitch keyword is used to mark the end of a switch conditional which was started with the switch syntax.
The PHP if keyword is used to create an if conditional. The elseif and else keywords can then be used to run code when the if condition is not met.