Javascript string lambda implementation