Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Operator in Javascript

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 121
    Comment on it

    There are following types of operators in JavaScript.

    1- Arithmetic Operators ( +,-,*,/,%,++,-- )

    <script>
    var a= 1;
    var b = 2;
    var c = a + b;
    document.getElementById("demo").innerHTML = c;
    </script>
    

    2- Comparison (Relational) Operators (==,===,!=,!==,>,>=,<=)

    <script type="text/javascript">
                         var a = 5;
                var b = 8;
                var linebreak = "<br />";
                document.write("(a == b) => ");
                result = (a == b);
                document.write(result);
                document.write(linebreak);
                document.write("(a < b) => ");
                result = (a < b);
                document.write(result);
                document.write(linebreak);
    </script>
    

    3-Bitwise Operators ( &,|,<<,>>,>>>, =>)

    <script type="text/javascript">
             <!--
                var a = 2; //variable taken
                var b = 3;
                var linebreak = "<br />";
                document.write("(a & b) => ");
                result = (a & b);
                document.write(result);
                document.write(linebreak);
    </script>
    

    4-Logical Operators (&&,||,!)

    <script type="text/javascript">
             <!--
                var x = true;
                var y = false;
                var linebreak = "<br />";
                document.write("(x && y) => ");
                result = (x && y);
                document.write(result);
                document.write(linebreak);
    </script>
    

    5-Assignment Operators (=,+=,-=,*=,/=)

    <script>
    var x = 10;
    x += 4;
    document.getElementById("demo").innerHTML = x;
    </script>
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: