CoffeeScript Interview QuestionsA list of frequently asked CoffeeScript Interview Questions are given below: 1) Define CoffeeScript.The CoffeeScript is a lightweight programing language that compiles into JavaScript. It is getting popular day by day because it provides better and more consistent syntax than JavaScript, still contains the flexibility and other advantages of JavaScript. 2) Who was the founder of CoffeeScript?The CoffeeScript was designed and developed by Jeremy Ashkenas in December 2009. 3) What was the primary purpose behind the invention of CoffeeScript?The primary purpose of CoffeeScript was to remove all the rough edges from JavaScript and provides a smooth way of programming in JavaScript. Using CoffeeScript, we can also create classes and inherit them. 4) Which languages have the most impact on CoffeeScript?Python, Ruby, and Haskell have inspired the CoffeeScript. It adopts syntax & coding styles from them, which makes it unique and useful. 5) What are the basic rules to remember for CoffeeScript?You must remember these rules for CoffeeScript:
6) Explain the advantages of CoffeeScript over JavaScript.Following is a list of advantages of CoffeeScript over JavaScript:
7) Explain the disadvantages of CoffeeScript over javascript.Following are some disadvantages of using CoffeeScript over javascript:
8) What is the difference between variables in CoffeeScript and JavaScript?In JavaScript, it is required to declare a variable using the var keyword and initialize it. However, in CoffeeScript, we can create a variable directly, by assigning the value to a literal such as: - name=variable value 9) Explain functions in CoffeeScript.The syntax of CoffeeScript's function is more straightforward than JavaScript's function. In CoffeeScript, you have to define function expressions. The function keyword is not used in CoffeeScript. Instead of this, you have to use an arrow symbol (->). 10) Why is CoffeeScript getting popularity day by day?The CoffeeScript is the 11th most popular language in Github. Its primary purpose is to produce efficient JavaScript without writing much code. It also focuses on highlighting all the functional aspects of JavaScript with a simple syntax. Reasons behind the popularity of CoffeeScript:
11) What are the disadvantages of CoffeeScript?
12) What are transpilers in CoffeeScript?In CoffeeScript, a tool is required to translate/ convert CoffeeScript codes into JavaScript. This tool is known as transpilers. 13) 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 ....) 14) What is the use of clone-function in CoffeeScript?In CoffeeScript, clone function is used to clone or duplicate an instance of an object. Create a clone() method which returns a new instance with copied values. For example: clone = (obj) -> return obj if obj is null or typeof (obj) isnt "object" temp = new obj.constructor() for key of obj temp[key] = clone(obj[key]) temp 15) Explain class methods in CoffeeScript?In CoffeeScript, class objects are stored in the object itself rather than on the object prototype. It saves memory and gives a central location to store class-level values. 16) 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. 17) 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 the way they handle references. The assignment only copies the reference of the object while clone-function creates an entirely new object. 18) How CoffeeScript interpolates the strings?The concept of Interpolation in CoffeeScript is same as Ruby. Most expressions of CoffeeScript are valid inside the #{...} interpolation syntax. 19) How do Boolean works with CoffeeScript?In CoffeeScript, "True" is generally represented as "On" or "Yes" and "False" is represented as "Off" or "No". 20) How can you create and delete a missing function in CoffeeScript?You can use the existential assignment operator (?=) to create and delete the missing function in CoffeeScript. 21) 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. 22) How can you map an array in CoffeeScript?You can map an array in the object by using map() with an anonymous function in CoffeeScript. For simple mapping, the list comprehension is more useful, because CoffeeScript directly support list comprehensions. 23) How can you use arrays to swap variables?You can use CoffeeScript's destructuring assignment syntax to swap variables using the array. It allows exchanging two values without the use of a temporary variable. 24) Why are Essential Operators are used in CoffeeScript?Existential Operators are used in CoffeeScript for the following reasons:
25) What is String interpolation in CoffeeScript? Give an example.The CoffeeScript provides a feature known as string interpolation used to include variables in the string. Ruby programming language inspires this feature. String interpolation is done using the above syntax. Using double quotes "", Hashtag #, and a pair of curly braces {}. For example: 26) What is string concatenation in CoffeeScript? How is it done?In CoffeeScript, we can easily concatenate two strings by using + operator between the two strings. For example: 27) What is string object in coffeeScript/javaScript? Explain its methods.The string object of javascript helps you work with the series of characters. String object provides various of methods to perform various operations in strings. We can use the javascript library in CoffeeScript code. Hence we can use all the methods of string object in javascript. Following are some of the methods of string object:
28) What is splat in CoffeeScript? Explain with an example.The CoffeeScript provides a feature known as splat which is used to pass multiple arguments to a function. We can use splats in functions by placing three dots after the variable name. For example: Explanation of the above example: In the above case of spats, multiple arguments were being passed to the function. By placing three dots after the argument list of the function indian_team. In the first pass we have passed four arguments to the function, in the second pass we have passed six arguments to the function, and in the last pass, we had passed the names of the full squad to the function. 29) Give an example to demonstrate the use of splats with tailing argument in CoffeeScript. Also, explain.The splats with tailing argument refer to the argument placed after the splat argument. For example: In the above example of using tailing with splats, we have placed an additional argument to the argument list of the indian_team function. 30) Give an example to demonstrate the use of comprehensions with splats.Within the function, we can also iterate the elements of a splat using comprehensions as shown in the following example. Save this code in a file with the name splats_comprehensions.coffee 31) Explain the various math functions which can be used in CoffeeScript.We can use the javascript library in CoffeeScript code. Hence we can use all the methods of math object in javascript. Following are some math function present in the math object: \
|