This study was the first to examine the role of BDNF in cognitive impairment in T2DM and prediabetes using mediation analysis. This evidence concerns the gene BDNF and Cognitive impairment.