I think this would be clearer as

```
var weight = $(this).data("weight");
if (weight == null) {
    weight = 0;
}
```