What happen to the counter value if I do not input the statement (if previous state!=current state)
No, it will increment as long as there is a product and at the frequency your loop runs at. So, when the light is interrupted, it will count several objects within a second.
The line you want to ommit is very essential, it makes the sketch only detect edges rather than levels.