I think I might be missing something here but it seems twig tags aren't parsed within tags? Is there any way they can be, e.g.:
<script>
var homepageStandfirstAnchors = [<% for anchor in homepage.homepageStandfirstAnchors %>[{{ anchor.text }},{{ anchor.section.handle }},{{ anchor.anchorLink }}],<% endfor %>];
</script>
doesn't work as expected.