JavaScript Tutorials - Herong's Tutorial Examples - 2.33, by Herong Yang
Operators and Expressions - Examples
This section provides a JavaScript tutorial example on using arithmetic, comparison, bitwise, and assignment operators.
Based on the description of operators and expressions given in the previous section, here is a JavaScript tutorial example that shows you different types of operators:
<html>
<!-- Operators.html
Copyright (c) 2002 HerongYang.com. All Rights Reserved.
-->
<head><title>Operators and Expressions</title></head>
<body>
<pre>
<script type="text/javascript">
document.write(10/3);
document.write('\n');
document.write(10%3);
document.write('\n');
document.write(1>0);
document.write('\n');
document.write('Five'>'One');
document.write('\n');
document.write(10=='10');
document.write('\n');
document.write(10==='10');
document.write('\n');
document.write(1<<3);
document.write('\n');
document.write(8>>3);
document.write('\n');
var comment;
document.write(comment='Assignment is expression');
document.write('\n');
</script>
</pre>
</body>
</html>
The output of this sample JavaScript is:
3.3333333333333335 1 true false true false 8 1 Assignment is expression
Table of Contents
ECMAScript Language Specification and JavaScript Dialects
►Data Types, Variables and Expressions
Primitive Data Types - Numbers, Strings, and Booleans
Declaring Variables - "var" Statements
►Operators and Expressions - Examples
Creating, Accessing, and Manipulating Arrays
Defining and Calling Functions
Web Browser Supporting JavaScript
Server-Side and Client-Side Web Scripting
Defining Your Own Object Types
Inheritance of Properties and Methods through the Prototype Object Chain
'jrunscript' - JavaScript Shell Command from JDK
Using Functions as "Function" Objects
Introduction to Built-in Object Types
W3C's Document Object Model (DOM) Specifications