Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 75 - 2609_Logicode
P. 75

    Operator        Name                          Description                    Example      Output

                          >=      greater than or  Checks if the left operand is greater than or     x >= 8      true
                                  equal to         equal to the right.
                          <=      less than or     Checks  if the  left operand  is less than or     x <= 8      true
                                  equal to         equal to the right.
                         ===      strict equality   Compares both the value and the data type  x === “8”         false

                                                   of two operands.

                     Logical Operators

                     The logic  between  variables or values is determined  using  logical  operators.  The table  below
                     explains the logical operators given a = 6 and b = 3:
                      Operator  Name                        Description                       Example          Output

                         &&        AND  Returns true if both operands are true; false if  (a < 10 && b > 1)      true
                                          either is false.
                          ||        OR    Returns false if both operands are false; true  (a == 5 || b == 5)    false
                                          if any one is true.

                          !        NOT  Inverts the  boolean  value (true  becomes  !(a == b)                    true
                                          false, false becomes true).

                     EXPRESSIONS
                     An expression  is a meaningful  combination  of variables, values and operators  which can be

                     evaluated and simplified to a single result.
                     For example,

                        area = length * breadth;

                     COMMENTS
                     Comments are instructions that are not executed by the interpreter. JavaScript code may also
                     include comments for the purpose of documentation and readability.

                     Two types of comments in JavaScript are as follows:

                       Single-line comment: This type of comment starts with //. For example,

                       // This is a single-line comment
                       let x = 5;

                       Multi-line comment: In this type of comment, text is enclosed between the characters /* and
                     */. For example,

                       /* This is a
                       multi-line comment */

                       let y = 10;

                                                                                               JavaScript for Beginners  73

| 70 71 72 73 74 75 76 77 78 79 80 |