Hi Selva,
this code snippet is working for me to get variable fonts used in a document:
var docFontsArray = app.documents[0].fonts.everyItem().getElements();
var variableFontsArray = [];
for( var n=0; n<docFontsArray.length; n++ )
{
if( "numDesignAxes" in docFontsArray[n].properties )
{
variableFontsArray[ variableFontsArray.length++ ] =
docFontsArray[n] ;
}
};
for( var n=0; n<variableFontsArray.length; n++ )
{
$.writeln( variableFontsArray[n].name );
};
No idea if it can detect every variable font in the world that can be used with InDesign.
Testing this way is pure empiric. For now that test is sufficient.
If it fails in your case, please do a screenshot of the dialog Type > Find/Replace fonts…, select the font and look into "More Information" what the details are ( screenshot from my German InDesign 2021 ) :

Regards,
Uwe Laubender
( ACP )