Fix #14892: Add undefined check before using the intializer of for-statment
--checkJs
--allowJs
// @ts-ignore
checkJs