I am very new to F# and i do more work with Javascript.
I just want to know whether it is possible to call a javascript function from F#.
Of course this Question may not show minimum effort. But i am just asking for an Idea
Thanks
I am very new to F# and i do more work with Javascript. I
Share
F# is mainly a server-side language. This means that compiled F# code runs on the server – you can expose some functionality written in F# as a REST service and call it from JavaScript using the usual AJAX style call.
If you want to follow this path, then the easiest option is to write the server-side code using some framework like ASP.NET MVC (this article explains how to use F# with MVC, examples of writing REST services mostly use C#, but it should be easy to translate them), or you can use
HttpListenerto write your own lightweight web server in F# (you can find some example here – the website currently has just source code, but there will be links to articles that explain it soon).Alternatively, there are some projects that allow you to write code F# and have it translated to JavaScript. Then you can run your entire F# program on the client-side (without any server). The JavaScript generated from F# can be probably also invoked from usual JavaScript code. Take a look at WebSharper and the FSharp.JavaScript project.