Comma operator in JavaScript

Comma operator in asp.net:



The comma operator evaluates each of its operands (from left to right) and returns the value of the last operand.

Syntax of Comma operator:

expr1, expr2, expr3...

Parameters
expr1, expr2, expr3...
Any expressions.

Description of Comma operator:

You can use the comma operator when you want to include multiple expressions in a location that requires a single expression. The most common usage of this operator is to supply multiple parameters in a for loop.

Comma operator Example:

If a is a 2-dimensional array with 10 elements on a side, the following code uses the comma operator to increment two variables at once. Note that the comma in the var statement is not the comma operator, because it doesn't exist within an expression. Rather, it is a special character in var statements to combine multiple of them into one. Practically, that comma behaves almost the same as the comma operator, though.

The code prints the values of the diagonal elements in the array:

for (var i = 0, j = 9; i <= 9; i++, j--)

  document.writeln("a[" + i + "][" + j + "] = " + a[i][j]); 


Other Related Post on this tutorial:


     ·          How to Bind gridview form database.·         Show gridview Row Details in Asp.net.·         Template field in gridview asp.net Example·         Introduction of  Asp.net grid view Control.·         Example of Templatefield in gridview.·         Example of  DropDownList  inside gridView·         Asp.net grid viewControl Programming.·         Checkbox within Asp.Net gridView·         Ckeckbox list Example using JavaScript in   gridview. ·         Asp.net textbox control in inside of gridview·         How to Bind Gridview Form database.·         Show gridview Row Details And Give Example.·         Example of Templatefield in asp.net gridview.·         Example of DropDownList inside GridView control·         Introduction of Asp.net grid view Control.·         Example of C# for Bind Data to asp.net Textbox inside gridview control·         Bind Data to asp.net textbox control in inside of gridview Using C# Example·         ListView.LayoutTemplate Property·         How to use table for ListView layout in asp.net·         How to use table layout in ListView control in ASP.Net·         How to use Asp ListView control in asp.net·         ASP.NET ListView Demo Data and layout templates ·         Checkboxlist control in asp net·         Example of Adding ToolTip for each Dropdown List Item in C#

Comments

  1. Thank you for this case description. Is really useful. I started my work upon one big project but I still have some questions about JavaScript nuances. This website helped me to find many answers.

    ReplyDelete

Post a Comment