May 09, 2021 CoffeeScript
You want to embed found or pre-written JavaScript code in CoffeeScript.
Wrap JavaScript into an apostrophe:
`function greet(name) {
return "Hello "+name;
}`
# Back to CoffeeScript
greet "Coffee"
# => "Hello Coffee"
This is the easiest way to integrate a small amount of JavaScript into The CoffeeScript code without having to convert them with the CoffeeScript syntax. As shown in CoffeeScript Language Reference, you can mix the code for both languages within a certain range:
hello = `function (name) {
return "Hello "+name
}`
hello "Coffee"
# => "Hello Coffee"
The variable "hello" here is still in CoffeeScript, but the function assigned to it is written in JavaScript.