Search All Articles Submit your Website or Blog to A New Internet Library
Monday, November 10, 2008
what is the difference between =.== and === ?
= is meant for assigning the one value to the other
== is meant for the comparision between string with number,number with number etc
===is meant for the comparision only number with number and string with the string
Example:
//for the EQUAL OPERATOR
if(x=y+z)
{
alert('true')
}
The above condition will be true if it is not containing any zero,false,and not containing any emptystring.
//for the DOUBLE EQUAL OPERATOR
if(x==y+z)
{
alert('true')
}
suppose the value of x is "3" and y and z is 5 nad -2 then the if condition vaulue is true and alert will come.Here we are comparing string with the number.
//for the TRIPLE EQUAL OPERATOR
if(x===y+z)
{
alert('true')
}
The above example is not possible because x value and the result of y+z value are either number and string.
if (3 === y + z) {alert('true');}
The above statement will still work if one of the equals is left out and unless one or other of y and z is a string containing a three and the other is an empty string the same result will be obtained if we accidentally leave out one of the equals. If we leave out two equals this statement generates a syntax error since 3 is not a variable and we therefore can't assign a value to it.
Also Read other Top Articles
- JSON Serialization in VS 2008
- Implementing Forms Authentication in Silverlight Application.
- Making GridView Rows or Individual Cells Clickable and Selectable.
- Enabling browser back button for GridView Paging and Sorting in Ajax 1.1 and 3.5 (using Visual Studio 2005/ Visual studio 2008)
- How to pass values from User Control to Page or calling Page methods from User Control.
- What is WCF?
- New features in C# 4.0
- C# to VB.NET and VB.NET to C# online free converter tools.


0 comments:
Post a Comment
Post your comments/questions/feedback for this Article.