Our results suggested that TNFα mediated the association between BMI z‐score and working memory only in adolescents (indirect effect = 0.09, 95% CI [0.03, 0.19]), whereas in adults, cortisol (indirect effect = −0.06, 95% CI [−0.13, −0.01]) and anxiety (indirect effect = 0.02, 95% CI [0.0001, 0.07]) mediated this association. This evidence concerns the gene TNF and Anxiety.