Hebrews 2:17–18 ESV
”Therefore he had to be made like his brothers in every respect, so that he might become a merciful and faithful high priest in the service of God, to make propitiation for the sins of the people. For because he himself has suffered when tempted, he is able to help those who are being tempted.”
Jesus became like us. He was born as a man into our world so he could endure our temptations. He not only suffered on the cross he also suffered through temptation. He did this without yielding to sin.
Therefore we can know that he knows by experience what we are going through in temptation. And we can know this in realizing he asks us to also resist temptation with his help.