Is it possible to add Javascript inside controller?

Is It possible to add javascript, etc inside a Controller?

If it possible, does it affects the security?

Thanks

Why would you want to put it in a controller? A view would be a more natural place for it.