How Weight Loss Is Tied To When You Eat And Not What You Eat

hello , i read somewhere that weight loss is tied to what i eat , and that i should avoid some certain food, but of recent i stumbled on an article saying what you eat doesn't determine your weight gain but when the food is eaten.

so how like to know if anyone agree to this topic, and do you you have practical examples to back it up?