FYI I’ve just added support for JavaScript variable declarations and assignment expressions in the latest v5.8.1 of #Script which will let you declare and assign variables with:
{{ var sliders = dirFiles('img/sliders') }}
See the announcement post for more examples.