Develop > Programming > Introduction to JavaScript in Service Manager > Using JavaScript in Service Manager > Avoiding the use of assignment instead of comparison

Avoiding the use of assignment instead of comparison

A common error in JavaScript code is the use of = (assignment), when a == (comparison) is actually intended.

Example of this issue

while ( rc = RC_SUCCESS)
{
// Do something with file here
rc = file.getNext();
}

A good practice to avoid this issue proactively, is to position the unchangeable value at the left side.

Recommended implementation

while ( RC_SUCCESS == rc)
{
// Do something with file here
rc = file.getNext();
}