CoffeeScript is a lightweight programming language that compiles into JavaScript. It provides simple and easy-to-learn syntax, avoiding the complex syntax of JavaScript. CoffeeScript is influenced by JavaScript, Ruby, YAML, Haskell, Perl, and Python and has influenced MoonScript, LiveScript, and JavaScript.
Example: The below example is demonstrating the conversion of CoffeeScript code into JavaScript code:
CoffeeScript
# Assignment:number  = 89opposite = falseÂ
# Functions:cube = (A) -> a * a * aÂ
# Conditions:number = -89 if !opposite |
JavaScript is the world’s most popular lightweight, interpreted, compiled programming language. It is also known as a scripting language for web pages. It is well-known for the development of web pages, and many non-browser environments also use it. JavaScript can be used for Client-side developments as well as Server-side development
Javascript
# Assignment:number = 89;opposite = false;Â
# Functions:cube = function (A) {Â Â Â Â return a * a * a;};Â
# Conditions:if (!opposite) {Â Â Â Â number = -89;} |
Now let us understand the step procedure of how to convert a CoffeeScript code into JavaScript with the example:
Step 1: Write CoffeeScript code and save the file with evenOrOdd.coffee extensionÂ
Javascript
// Write coffeeScript program to check whether // given number is even or odd Â
number = 12if number % 2 == 0    console.log "number is even"else    console.log "number is odd" |
Step 2: To run the evenOrOdd.coffee file, you need to type the following command :Â
coffee -c evenOrOdd.coffee
Step 3: After successful compilation of the above evenOrOdd.coffee file, the following JavaScript file will generate.
Javascript
(function () {Â Â Â Â var number;Â Â Â Â number = 12;Â
    if (number % 2 === 0) {        console.log("number is even");    } else {        console.log("number is odd");    }Â
}).call(this); |
Output:Â
number is even
This is how you can convert CoffeeScript code into JavaScript.
You can refer to any online editor to convert CoffeeScript code into JavaScript.
