You can't do it in pure JS. You need at least a PHP layer for authentication. Assuming that works for you, you can either use the REST API or the Javascript Munchkin API, both outlined here: http://developers.marketo.com/
You want the http://developers.marketo.com/documentation/rest/createupdate-leads/ for REST and this for the JS API http://developers.marketo.com/documentation/websites/lead-tracking-munchkin-js/ (scroll down to Associate Lead)