CoffeeScript — The Easier Javascript

Image for post
Image for post

Introduction

Getting Started With CoffeeScript

npm install --global coffeescript

Coding In CoffeeScript

Javascript

let name = "Mar"
name = "Mary"
const name = "Mar"
name = "Mary" //This will give a strict mode error.

CoffeeScript

name = "Mar"

Conditional Operations

Javascript

let check = true;
if (check === true) {
alert("The condition is met!")
}

CoffeeScript

check = true;
alert("The condition is met!") if check
alert("name is declared") if name?

Creating Objects and Arrays

Javascript

const addressBook = { contact1: {name: 'mark', email: 'mark@example.com', phone: '000-000-0000'}, contact2: {name: 'mary', email: 'mary@example.com', phone: '111-111-1111'}
}
const VIPList = ['Mark Henderson', 'James Dean', 'Anna Banana', 'Freddy Krueger']

CoffeeScript

     addressBook = 
contact1:
name: 'mark'
email: 'mark@example.com'
phone: '000-000-0000'
contact2:
name: 'mary'
email: 'mary@example.com'
phone: '111-111-1111'
VIPList = [
'Mark Henderson'
'James Dean'
'Anna Banana'
'F
reddy Krueger']

Functions

Javascript

const sayHello = function(greeting) {
console.log(greeting)
}
const sayHello = greeting => console.log(greeting) 

CoffeeScript

sayHello = (greeting) -> console.log(greeting)

Summary

Software Engineer focused on Full Stack development with MERN stack and Ruby experience. Interested in sharing my learning journey with aspiring developers.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store