Home arrow JavaScript arrow Page 3 - The Power of Javascript: Operators continued
JAVASCRIPT

The Power of Javascript: Operators continued


In the last article we talked about some of the unary and binary operators available in Javascript, namely the arithmetic operators, the comparison operators and the increment/decrement operators. In this article we continue our discussion of the Javascript operators; we will discuss how computers represent data, and bitwise operators.

Author Info:
By: Michael Youssef
Rating: 5 stars5 stars5 stars5 stars5 stars / 10
July 26, 2005
TABLE OF CONTENTS:
  1. · The Power of Javascript: Operators continued
  2. · Bitwise Operators
  3. · The Bitwise Operators Example
  4. · Assignment Operators
  5. · Assignment Operators Example

print this article
SEARCH DEVARTICLES

The Power of Javascript: Operators continued - The Bitwise Operators Example
(Page 3 of 5 )

Copy the following code, then paste it in a file and save it as an HTML document:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <title>Hello World</title>
    <script language="JavaScript" type="text/javascript">
      // x represented in binary as 00000101
      var x = 5;
      // y represented in binary as 00001001
      var y = 9;
      result = x & y;
      document.write(result + "<br>");
      result = x | y;
      document.write(result + "<br>");
      result = x ^ y;
      document.write(result + "<br>");
      result = ~4294967292;
      document.write(result + "<br>");
      result = y << 2;
      document.write(result + "<br>");
      result = y >> 2;
      document.write(result + "<br>"); 
    </script>
  </head>
  <body>
  </body>
</html>

When you load this file into your browser you will get the following values:

There's nothing special about this example because we have explained the bitwise operators in the above section. As I said before, the bitwise operators do not have much use in Javascript when you program in the browser, but it's part of the language and we should understand what these operators do. Next, we discuss the assignment operators.


blog comments powered by Disqus
JAVASCRIPT ARTICLES

- Project Nashorn to Make Java, JavaScript Wor...
- JavaScript Virus Attacks Tumblr Blogs
- Google Releases Stable Dart Version, JavaScr...
- Khan Academy Unveils New JavaScript Learning...
- Accessing Nitro? There`s an App for That
- JQuery 2.0 Leaving Older IE Versions Behind
- Fastest JavaScript Engine Might Surprise You
- Microsoft Adjusting Chakra for IE 10
- Brendan Eich: We Don`t Need Google Native Cl...
- An Overview of JavaScript Statements
- An Overview of JavaScript Operators
- Overview of JavaScript Variables
- More of the Top jQuery Social Plugins
- The Top jQuery Social Plugins
- More of the Top jQuery Slider Plugins

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials