Skip to content

micahlanham/regex-tutorial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

OR Operator Regex

Here below will be a explanation of OR Operator and how it functions

Summary

The OR operator is a Boolean operator which would return the value TRUE or Boolean value of 1 if either or both of the operands are TRUE or have Boolean value of 1. The OR operator is considered one of the basic logical operators along with AND and NOT in Boolean algebra. It is widely used in programming languages which support logical and comparison operators.

The OR operator can also be used in combination with other logical operators.

Xnip2021-10-10_12-17-57

Table of Contents

Syntax

Xnip2021-10-10_12-16-15

Description of Syntax

Xnip2021-10-10_11-48-13

Short circuit evaluation

The logical OR expression is evaluated left to right, it is tested for possible "short-circuit" evaluation using the following rule:

(some truthy expression) || expr is short-circuit evaluated to the truthy expression.

Short circuit means that the expr part above is not evaluated, hence any side effects of doing so do not take effect (e.g., if expr is a function call, the calling never takes place). This happens because the value of the operator is already determined after the evaluation of the first operand.

Xnip2021-10-10_12-22-08

Operator precedence

The following expressions might seem equivalent, but they are not, because the && operator is executed before the || operator

Xnip2021-10-10_12-24-40

Examples

Xnip2021-10-10_11-48-13

Author

New to coding, yet have been able to use my available resources to succeed in my tasks

https://github.com/micahlanham

Sources

First description from: https://www.techopedia.com/definition/3486/or-operator

Descriptions & Code snippets from: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_OR

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published