Can i mix handlebars with javascript

hello everyone ,
i’m new to ghost so i was wondering if i can use handlebars with javascript code or if there is any way to workaround this , this is example about what i mean
{{#foreach posts}}

thanks in advance

If you’re trying to log the context, there’s a {{log posts}} helper. If you’re trying to do data transformations on the server (e.g. posts[0] = 'bob'), that’s intentionally not allowed

thanks for your response
no , this is not what i want .
i’m creating search engine but i’m not allowed to use any plugin , so i’m working with vanilla javascript and wanna get posts to continue my script
if you have any ideas about creating something like that please tell me
thanks in advance