Sackling
Sackling

Reputation: 1820

What is "if (1.0)" checking for?

I am adding a piece of tracking code for adwords that is meant to track the amount of the sale. here is the code:

<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = 1234;
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
if (1.0) {
  var google_conversion_value = <?php echo round($order_total['value'],2);?>;
}
var google_conversion_label = "labelid";
var google_conversion_value = 0;
var google_remarketing_only = false;
/* ]]> */
</script>

The part I don't understand is the if statement if (1.0)

What is that checking for? why if 1.0? Is this a javascript thing?

Upvotes: 0

Views: 83

Answers (1)

Paul S.
Paul S.

Reputation: 66364

What is that checking for? why if 1.0? Is this a javascript thing?

1.0 === 1; // true, simplification

So

if (1) // ...

And

!!1 === true; // true, conversion to boolean

So

if (true) // ...

So it's basically an unnecessary if, but it does mean you could "switch off" some code easily when by editing the file

Upvotes: 1

Related Questions