trainingtrains Logo

91-9990449935

 0120-4256464

CoffeeScript Interview Questions

A list of frequently asked CoffeeScript Interview Questions are given below:


1) What is CoffeeScript?

CoffeeScript is a small programming language that compiles into JavaScript. It facilitates the users to write JavaScript code better by providing a more consistent syntax and avoiding the irregular nature of JavaScript language.


2) Who was the founder of CoffeeScript?

CoffeeScript was designed and developed by Jeremy Ashkenas in December, 2009.


3) What was the main purpose behind the invention of CoffeeScript?

The main purpose of CoffeeScript was to remove all the rough edges from JavaScript and provides a smooth way of programming in JavaScript.


4) Which languages have the most impact on CoffeeScript?

CoffeeScript has been inspired by Python, Ruby and Haskell, it adopted syntax & coding styles from them, which makes it very unique & Useful.


5) What are the basic rules to remember for CoffeeScript?

You must remember these rules for CoffeeScript:

Whitespace matters: There are no curly braces in CoffeeScript.

No parentheses: No need of parenthesis for functions that take arguments.


6) What are the advantages of CoffeeScript over JavaScript?

  • You can express your program with a lot less code with CoffeeScript rather than JavaScript.
  • It has a lot of lightweight add-ons like Ruby string Interpolation and Python style list comprehension.
  • Makes everyday tasks easier to perform with CoffeScript rather than JavaScript.

7) What is the difference between variables in CoffeeScript and JavaScript?

You have to add semicolon at the end of statements to execute variables in JavaScript while in CoffeeScript there is no need to add Semi-colon at the end of the statement.


8) What is function in CoffeeScript?

Functions in CoffeeScript is an (Optional) list of parameters followed by an arrow and then the function body.

For example, log = (message) -> console.log message


9) Why is CoffeeScript getting popularity day by day?

CoffeeScript is the 11th most popular language in Github. Its main purpose is to produce efficient JavaScript without writing much code. It also focuses on highlighting all the good aspects of JavaScript with simple syntax.

Reasons behind the popularity of CoffeeScript:

  • Very Little Coding is required when programming in CoffeeScript as compared to JavaScript.
  • CoffeeScript includes all the good features of JavaScript.
  • You can use any existing JavaScript library seamlessly with CoffeeScript.

10) What are the disadvantages of CoffeeScript?

  • CoffeeScript includes an additional compilation step while compilation.
  • Only a few resources are available for this language.

11) What is transpilers in CoffeeScript?

In CoffeeScript, a tool is required to translate/ convert CoffeeScript codes into JavaScript. This tool is known as transpilers.


12) What is splat in CoffeeScript?

Splat is the term used for (. . .) operator for var-argument. Splatted arguments can come either before, after or between standard arguments

For example, (first, rest . . .)


13) What is the use of clone-function in CoffeeScript?

Clone-function is used to create a complete new object in CoffeeScript by follow these steps:

  • Copying all attributes from the source object to the new object.
  • Repeating the steps of copying attributes from the source object for all sub-objects by calling the clone-function.
  • Creating a new object as the source object.

14) Explain class methods in CoffeeScript?

In CoffeeScript, class objects are stored in object itself rather than on the object prototype. It saves memory and gives a central location to store class-level values.


15) How can you replace a portion of strings with another value?

You can use Regular Expression to match and replace a portion of a string with another value.


16) What is the difference between copying an object through assignment and clone-function?

The main difference between copying an object through assignment and clone-function is that how they handle references. The assignment only copies the reference of the object while clone-function creates a complete new object.


17) How CoffeeScript interpolates the strings?

The concept of Interpolation in CafffeeScript is same as Ruby. Most expressions of CoffeeScript are valid inside the #{...} interpolation syntax.


18) How does Boolean works with CoffeeScript?

in CoffeeScript is same as other but instead of "True" or "False". In CoffeeScript, "True" is generally represented as "On" or "Yes" and "False" is represented as "Off" or "No".


19) How can you create and delete a missing function in CoffeeScript?

You can use the existential assignment operator (?=) to create and delete missing function in CoffeeScript.


20) Is it possible to bind parameters to properties in CoffeeScript?

Yes, You can bind parameters to properties in CoffeeScript by using @ shorthand. It can also be used to define class functions.


21) How can you map an array in CoffeeScript?

You can map an array in object by using map() with an anonymous function in CoffeeScript. For

simple mapping, list comprehension is more useful, because CoffeeScript directly support list

comprehensions.


22) How can you use arrays to swap variables?

You can use CoffeeScript's destructuring assignment syntax to swap variables using array. It allows

swapping two values without the use of a temporary variable.


23) Why Essential Operators are used in CoffeeScript?

Existential Operators are used in CoffeeScript for the following reasons:

  • To check the existence of a variable.
  • For conditional assignment.
  • For function chaining.