Relational Operators Precedence and Associativity in TypeScript
Operators in TypeScript have rules of Precedence and Associativity that determine how expressions are evaluated. Here I describe Precedence and Associativity separately.
Precedence
Associativity
| Precedence | Operator | Associativity |
| Equal | > >= < <= != == | Left-Right |
For example, if we write this code:
- if (true == > 2 <= true) {
- document.write("The value is True");
- } else {
- document.write("False");
- }
- if (2 <= true)
Step 1
Open Visual Studio 2012 and click on "File" menu -> "New" -> "Project". A window will be opened, provide the name of your application like "RelationalOperators", then click on the Ok button.
Step 2
After Step 1 your project has been created. The Solution Explorer, which is at the right side of Visual Studio, contains the js file, ts file, css file and html files.
Step 3
The code of the Relational operator's program.
RelationalOperators.ts
- class RelationOperators {
- MyFunction() {
- var a = 4,
- b = 2;
- if (true == a > b <= true) {
- document.write("The value is True");
- } else {
- document.write("False");
- }
- }
- }
- window.onload = () => {
- var call = new RelationOperators();
- call.MyFunction();
- }
default.html
- < !DOCTYPEhtml >
- <
- htmllang = "en"
- xmlns = "http://www.w3.org/1999/xhtml" >
- <
- head >
- <
- metacharset = "utf-8" / >
- <
- title > TypeScript HTML App < /title>
- <
- linkrel = "stylesheet"
- href = "app.css"
- type = "text/css" / >
- <
- scriptsrc = "app.js" > < /script>
- <
- /head>
- <
- body >
- <
- divid = "content" / >
- <
- /body> <
- /html>
app.js
- var RelationOperators = (function() {
- function RelationOperators() {}
- RelationOperators.prototype.MyFunction = function() {
- var a = 4;
- var b = 2;
- if (true == a > b <= true) {
- document.write("The value is True");
- } else {
- document.write("False");
- }
- };
- return RelationOperators;
- })();
- window.onload = function() {
- var call = new RelationOperators();
- call.MyFunction();
- };
Step 4
The output of the program looks like:

Join the conversation! Your thoughts help the community grow.