SlideShare uma empresa Scribd logo
1 de 21
Baixar para ler offline
CoffeeScript
CoffeeScript - Intro
@d_danailov
CoffeeScript : Intro
Dimitar Danailov
Senior Developer at 158ltd.com
dimityr.danailov[at]gmail.com
Github
Founder at VarnaIT
Senior Developer at 158ltd.com
Cleaner Code With CoffeeScript
Github Code
Topics Today
● Introduction
● Installing CoffeeScript
● Using CoffeeScript Files
● Learning the Core Functionality
● Data Types
● Comments and Functions
● Operators
Topics Today (2)
● Control Structures
● Loops and Comprehensions
● Scope and Context
● Stirring in Advanced Concepts
● Object Prototypes
● CoffeeScript Classes
● Heregexes
● Using CoffeeScript in the Browser
Installing CoffeeScript
1. Node.js
2. NPM
sudo apt-get install nodejs npm &&
3. sudo npm install -g coffee-script
4. coffee -v
Using CoffeeScript Files
node.js file.js
coffee file.coffee
coffee -c file.coffee
coffee -cw file.coffee
coffee (read–eval–print loop (REPL))
Variables
Booleans :
● true/false
● yes/no
● on/off
Variables (2)
Destructuring Assignment :
theBait = 1000
theSwitch = 0
[theBait, theSwitch ] = [theSwitch, theBait]
Variables (3)
Destructuring Assignment :
weatherReport = (location) ->
# Make an Ajax request to fetch the weather...
[location, 72, "Mostly Sunny" ]
[city, temp, forecast ] = weatherReport "Berkeley, CA"
Comments
# Single line comment
###
Multi line comment
###
Functions
Splats :
The JavaScript arguments object is a useful way to work with functions that
accept variable numbers of arguments. CoffeeScript provides splats ..., both
for function definition as well as invocation, making variable numbers of
arguments a little bit more palatable.
# Splats:
race = (winner, runners...) ->
print winner, runners
Operators
● JS : == / Coffee : is
● JS : != / Coffee : isnt
● JS : if (!false) / Coffee : if not false
● JS : && / Coffee : AND
● JS : || / Coffee : OR
Condition statements
● if
● if not
● unless
● switch and when
Loops and Comprehensions
Most of the loops you'll write in CoffeeScript will be comprehensions over
arrays, objects, and ranges. Comprehensions replace (and compile into) for
loops, with optional guard clauses and the value of the current array index.
Unlike for loops, array comprehensions are expressions, and can be returned
and assigned.
Loops
● for
● while
● until
● loop used with break !!!
Scope
● coffee -c --bare file.coffee
● this
● root = (export ? window)
Prototype
Classes
Regular Expressions
Similar to block strings and comments, CoffeeScript supports block regexes
— extended regular expressions that ignore internal whitespace and can
contain comments and interpolation. Modeled after Perl's /x modifier,
CoffeeScript's block regexes are delimited by /// and go a long way towards
making complex regular expressions readable.
Using CoffeeScript in the Browser
● coffee -c --watch *.coffee
● coffee -c --watch o js src/*.coffee
● http://coffeescript.org/#scripts
Questions ?
Dimitar Danailov
Senior Developer at 158ltd.com
dimityr.danailov[at]gmail.com
Github
Founder at VarnaIT
Senior Developer at 158ltd.com
Cleaner Code With CoffeeScript
Github Code

Mais conteúdo relacionado

Semelhante a Coffeescript intro

Road to sbt 1.0 paved with server
Road to sbt 1.0   paved with serverRoad to sbt 1.0   paved with server
Road to sbt 1.0 paved with serverEugene Yokota
 
Intro - End to end ML with Kubeflow @ SignalConf 2018
Intro - End to end ML with Kubeflow @ SignalConf 2018Intro - End to end ML with Kubeflow @ SignalConf 2018
Intro - End to end ML with Kubeflow @ SignalConf 2018Holden Karau
 
Angular 2 overview
Angular 2 overviewAngular 2 overview
Angular 2 overviewJesse Warden
 
High Performance TensorFlow in Production -- Sydney ML / AI Train Workshop @ ...
High Performance TensorFlow in Production -- Sydney ML / AI Train Workshop @ ...High Performance TensorFlow in Production -- Sydney ML / AI Train Workshop @ ...
High Performance TensorFlow in Production -- Sydney ML / AI Train Workshop @ ...Chris Fregly
 
Writing Bullet-Proof Javascript: By Using CoffeeScript
Writing Bullet-Proof Javascript: By Using CoffeeScriptWriting Bullet-Proof Javascript: By Using CoffeeScript
Writing Bullet-Proof Javascript: By Using CoffeeScriptSusan Potter
 
Performance and Scalability
Performance and ScalabilityPerformance and Scalability
Performance and ScalabilityMediacurrent
 
Makefile for python projects
Makefile for python projectsMakefile for python projects
Makefile for python projectsMpho Mphego
 
Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...
Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...
Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...Develcz
 
Scalding by Adform Research, Alex Gryzlov
Scalding by Adform Research, Alex GryzlovScalding by Adform Research, Alex Gryzlov
Scalding by Adform Research, Alex GryzlovVasil Remeniuk
 
Daniel Steigerwald - Este.js - konec velkého Schizma
Daniel Steigerwald - Este.js - konec velkého SchizmaDaniel Steigerwald - Este.js - konec velkého Schizma
Daniel Steigerwald - Este.js - konec velkého SchizmaDevelcz
 
Configuring in the Browser, Really!
Configuring in the Browser, Really!Configuring in the Browser, Really!
Configuring in the Browser, Really!Tim Geisler
 
Drupal performance and scalability
Drupal performance and scalabilityDrupal performance and scalability
Drupal performance and scalabilityTwinbit
 
Optimize + Deploy Distributed Tensorflow, Spark, and Scikit-Learn Models on G...
Optimize + Deploy Distributed Tensorflow, Spark, and Scikit-Learn Models on G...Optimize + Deploy Distributed Tensorflow, Spark, and Scikit-Learn Models on G...
Optimize + Deploy Distributed Tensorflow, Spark, and Scikit-Learn Models on G...Chris Fregly
 
Deployments with rails
Deployments with railsDeployments with rails
Deployments with railsGourav Tiwari
 
Build optimization mechanisms in GitLab and Docker
Build optimization mechanisms in GitLab and DockerBuild optimization mechanisms in GitLab and Docker
Build optimization mechanisms in GitLab and DockerDmytro Patkovskyi
 

Semelhante a Coffeescript intro (20)

Road to sbt 1.0 paved with server
Road to sbt 1.0   paved with serverRoad to sbt 1.0   paved with server
Road to sbt 1.0 paved with server
 
Smooth CoffeeScript
Smooth CoffeeScriptSmooth CoffeeScript
Smooth CoffeeScript
 
Intro - End to end ML with Kubeflow @ SignalConf 2018
Intro - End to end ML with Kubeflow @ SignalConf 2018Intro - End to end ML with Kubeflow @ SignalConf 2018
Intro - End to end ML with Kubeflow @ SignalConf 2018
 
Angular 2 overview
Angular 2 overviewAngular 2 overview
Angular 2 overview
 
High Performance TensorFlow in Production -- Sydney ML / AI Train Workshop @ ...
High Performance TensorFlow in Production -- Sydney ML / AI Train Workshop @ ...High Performance TensorFlow in Production -- Sydney ML / AI Train Workshop @ ...
High Performance TensorFlow in Production -- Sydney ML / AI Train Workshop @ ...
 
Writing Bullet-Proof Javascript: By Using CoffeeScript
Writing Bullet-Proof Javascript: By Using CoffeeScriptWriting Bullet-Proof Javascript: By Using CoffeeScript
Writing Bullet-Proof Javascript: By Using CoffeeScript
 
Autolab Workshop
Autolab WorkshopAutolab Workshop
Autolab Workshop
 
Performance and Scalability
Performance and ScalabilityPerformance and Scalability
Performance and Scalability
 
Makefile for python projects
Makefile for python projectsMakefile for python projects
Makefile for python projects
 
Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...
Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...
Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...
 
Scaling PHP apps
Scaling PHP appsScaling PHP apps
Scaling PHP apps
 
Scalding by Adform Research, Alex Gryzlov
Scalding by Adform Research, Alex GryzlovScalding by Adform Research, Alex Gryzlov
Scalding by Adform Research, Alex Gryzlov
 
Daniel Steigerwald - Este.js - konec velkého Schizma
Daniel Steigerwald - Este.js - konec velkého SchizmaDaniel Steigerwald - Este.js - konec velkého Schizma
Daniel Steigerwald - Este.js - konec velkého Schizma
 
Coffee script throwdown
Coffee script throwdownCoffee script throwdown
Coffee script throwdown
 
Configuring in the Browser, Really!
Configuring in the Browser, Really!Configuring in the Browser, Really!
Configuring in the Browser, Really!
 
Drupal performance and scalability
Drupal performance and scalabilityDrupal performance and scalability
Drupal performance and scalability
 
Optimize + Deploy Distributed Tensorflow, Spark, and Scikit-Learn Models on G...
Optimize + Deploy Distributed Tensorflow, Spark, and Scikit-Learn Models on G...Optimize + Deploy Distributed Tensorflow, Spark, and Scikit-Learn Models on G...
Optimize + Deploy Distributed Tensorflow, Spark, and Scikit-Learn Models on G...
 
Deployments with rails
Deployments with railsDeployments with rails
Deployments with rails
 
PHP Development Tools
PHP  Development ToolsPHP  Development Tools
PHP Development Tools
 
Build optimization mechanisms in GitLab and Docker
Build optimization mechanisms in GitLab and DockerBuild optimization mechanisms in GitLab and Docker
Build optimization mechanisms in GitLab and Docker
 

Mais de Dimitar Danailov

Evolution - ReConnect() 2019
Evolution - ReConnect() 2019Evolution - ReConnect() 2019
Evolution - ReConnect() 2019Dimitar Danailov
 
Data Visualization and D3Js
Data Visualization and D3JsData Visualization and D3Js
Data Visualization and D3JsDimitar Danailov
 
#Productivity - {S:01 Ep:03}
#Productivity - {S:01 Ep:03} #Productivity - {S:01 Ep:03}
#Productivity - {S:01 Ep:03} Dimitar Danailov
 
#Productivity - {S:01 Ep:02}
#Productivity - {S:01 Ep:02}#Productivity - {S:01 Ep:02}
#Productivity - {S:01 Ep:02}Dimitar Danailov
 
Cloud Conf Varna - Cloud Application with AWS Lambda functions
Cloud Conf Varna - Cloud Application with AWS Lambda functionsCloud Conf Varna - Cloud Application with AWS Lambda functions
Cloud Conf Varna - Cloud Application with AWS Lambda functionsDimitar Danailov
 
DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)
DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)
DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)Dimitar Danailov
 
Building modern Progressive Web Apps with Polymer
Building modern Progressive Web Apps with PolymerBuilding modern Progressive Web Apps with Polymer
Building modern Progressive Web Apps with PolymerDimitar Danailov
 
Typescript - MentorMate Academy
Typescript - MentorMate AcademyTypescript - MentorMate Academy
Typescript - MentorMate AcademyDimitar Danailov
 
HackConf2016 - Ruby on Rails: Unexpected journey
HackConf2016 - Ruby on Rails: Unexpected journeyHackConf2016 - Ruby on Rails: Unexpected journey
HackConf2016 - Ruby on Rails: Unexpected journeyDimitar Danailov
 
Microservices - Code Voyagers Sofia
Microservices - Code Voyagers SofiaMicroservices - Code Voyagers Sofia
Microservices - Code Voyagers SofiaDimitar Danailov
 
Mongo DB Terms - Mentormate Academy
Mongo DB Terms - Mentormate AcademyMongo DB Terms - Mentormate Academy
Mongo DB Terms - Mentormate AcademyDimitar Danailov
 
Startup Europe Week - Cloud Conf Varna & GDG Varna
Startup Europe Week - Cloud Conf Varna & GDG VarnaStartup Europe Week - Cloud Conf Varna & GDG Varna
Startup Europe Week - Cloud Conf Varna & GDG VarnaDimitar Danailov
 
MicroServices: Advantages ans Disadvantages
MicroServices: Advantages ans DisadvantagesMicroServices: Advantages ans Disadvantages
MicroServices: Advantages ans DisadvantagesDimitar Danailov
 
Softuni.bg - Microservices
Softuni.bg - MicroservicesSoftuni.bg - Microservices
Softuni.bg - MicroservicesDimitar Danailov
 
Cloud Conf Varna: Vagrant and Amazon
Cloud Conf Varna: Vagrant and AmazonCloud Conf Varna: Vagrant and Amazon
Cloud Conf Varna: Vagrant and AmazonDimitar Danailov
 
HackConf2015 - Ruby on Rails: Unexpected journey
HackConf2015 - Ruby on Rails: Unexpected journeyHackConf2015 - Ruby on Rails: Unexpected journey
HackConf2015 - Ruby on Rails: Unexpected journeyDimitar Danailov
 

Mais de Dimitar Danailov (20)

Evolution - ReConnect() 2019
Evolution - ReConnect() 2019Evolution - ReConnect() 2019
Evolution - ReConnect() 2019
 
Data Visualization and D3Js
Data Visualization and D3JsData Visualization and D3Js
Data Visualization and D3Js
 
#Productivity - {S:01 Ep:03}
#Productivity - {S:01 Ep:03} #Productivity - {S:01 Ep:03}
#Productivity - {S:01 Ep:03}
 
#Productivity - {S:01 Ep:02}
#Productivity - {S:01 Ep:02}#Productivity - {S:01 Ep:02}
#Productivity - {S:01 Ep:02}
 
#Productivity s01 ep02
#Productivity s01 ep02#Productivity s01 ep02
#Productivity s01 ep02
 
#Productivity s01 ep01
#Productivity s01 ep01#Productivity s01 ep01
#Productivity s01 ep01
 
Cloud Conf Varna - Cloud Application with AWS Lambda functions
Cloud Conf Varna - Cloud Application with AWS Lambda functionsCloud Conf Varna - Cloud Application with AWS Lambda functions
Cloud Conf Varna - Cloud Application with AWS Lambda functions
 
DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)
DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)
DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)
 
Building modern Progressive Web Apps with Polymer
Building modern Progressive Web Apps with PolymerBuilding modern Progressive Web Apps with Polymer
Building modern Progressive Web Apps with Polymer
 
Typescript - MentorMate Academy
Typescript - MentorMate AcademyTypescript - MentorMate Academy
Typescript - MentorMate Academy
 
HackConf2016 - Ruby on Rails: Unexpected journey
HackConf2016 - Ruby on Rails: Unexpected journeyHackConf2016 - Ruby on Rails: Unexpected journey
HackConf2016 - Ruby on Rails: Unexpected journey
 
Microservices - Code Voyagers Sofia
Microservices - Code Voyagers SofiaMicroservices - Code Voyagers Sofia
Microservices - Code Voyagers Sofia
 
Mongo DB Terms - Mentormate Academy
Mongo DB Terms - Mentormate AcademyMongo DB Terms - Mentormate Academy
Mongo DB Terms - Mentormate Academy
 
Startup Europe Week - Cloud Conf Varna & GDG Varna
Startup Europe Week - Cloud Conf Varna & GDG VarnaStartup Europe Week - Cloud Conf Varna & GDG Varna
Startup Europe Week - Cloud Conf Varna & GDG Varna
 
GDG Varna - Hadoop
GDG Varna - HadoopGDG Varna - Hadoop
GDG Varna - Hadoop
 
MicroServices: Advantages ans Disadvantages
MicroServices: Advantages ans DisadvantagesMicroServices: Advantages ans Disadvantages
MicroServices: Advantages ans Disadvantages
 
GDG Varna - EcmaScript 6
GDG Varna - EcmaScript 6GDG Varna - EcmaScript 6
GDG Varna - EcmaScript 6
 
Softuni.bg - Microservices
Softuni.bg - MicroservicesSoftuni.bg - Microservices
Softuni.bg - Microservices
 
Cloud Conf Varna: Vagrant and Amazon
Cloud Conf Varna: Vagrant and AmazonCloud Conf Varna: Vagrant and Amazon
Cloud Conf Varna: Vagrant and Amazon
 
HackConf2015 - Ruby on Rails: Unexpected journey
HackConf2015 - Ruby on Rails: Unexpected journeyHackConf2015 - Ruby on Rails: Unexpected journey
HackConf2015 - Ruby on Rails: Unexpected journey
 

Último

Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 

Último (20)

Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 

Coffeescript intro

  • 2. CoffeeScript : Intro Dimitar Danailov Senior Developer at 158ltd.com dimityr.danailov[at]gmail.com Github Founder at VarnaIT Senior Developer at 158ltd.com Cleaner Code With CoffeeScript Github Code
  • 3. Topics Today ● Introduction ● Installing CoffeeScript ● Using CoffeeScript Files ● Learning the Core Functionality ● Data Types ● Comments and Functions ● Operators
  • 4. Topics Today (2) ● Control Structures ● Loops and Comprehensions ● Scope and Context ● Stirring in Advanced Concepts ● Object Prototypes ● CoffeeScript Classes ● Heregexes ● Using CoffeeScript in the Browser
  • 5. Installing CoffeeScript 1. Node.js 2. NPM sudo apt-get install nodejs npm && 3. sudo npm install -g coffee-script 4. coffee -v
  • 6. Using CoffeeScript Files node.js file.js coffee file.coffee coffee -c file.coffee coffee -cw file.coffee coffee (read–eval–print loop (REPL))
  • 8. Variables (2) Destructuring Assignment : theBait = 1000 theSwitch = 0 [theBait, theSwitch ] = [theSwitch, theBait]
  • 9. Variables (3) Destructuring Assignment : weatherReport = (location) -> # Make an Ajax request to fetch the weather... [location, 72, "Mostly Sunny" ] [city, temp, forecast ] = weatherReport "Berkeley, CA"
  • 10. Comments # Single line comment ### Multi line comment ###
  • 11. Functions Splats : The JavaScript arguments object is a useful way to work with functions that accept variable numbers of arguments. CoffeeScript provides splats ..., both for function definition as well as invocation, making variable numbers of arguments a little bit more palatable. # Splats: race = (winner, runners...) -> print winner, runners
  • 12. Operators ● JS : == / Coffee : is ● JS : != / Coffee : isnt ● JS : if (!false) / Coffee : if not false ● JS : && / Coffee : AND ● JS : || / Coffee : OR
  • 13. Condition statements ● if ● if not ● unless ● switch and when
  • 14. Loops and Comprehensions Most of the loops you'll write in CoffeeScript will be comprehensions over arrays, objects, and ranges. Comprehensions replace (and compile into) for loops, with optional guard clauses and the value of the current array index. Unlike for loops, array comprehensions are expressions, and can be returned and assigned.
  • 15. Loops ● for ● while ● until ● loop used with break !!!
  • 16. Scope ● coffee -c --bare file.coffee ● this ● root = (export ? window)
  • 19. Regular Expressions Similar to block strings and comments, CoffeeScript supports block regexes — extended regular expressions that ignore internal whitespace and can contain comments and interpolation. Modeled after Perl's /x modifier, CoffeeScript's block regexes are delimited by /// and go a long way towards making complex regular expressions readable.
  • 20. Using CoffeeScript in the Browser ● coffee -c --watch *.coffee ● coffee -c --watch o js src/*.coffee ● http://coffeescript.org/#scripts
  • 21. Questions ? Dimitar Danailov Senior Developer at 158ltd.com dimityr.danailov[at]gmail.com Github Founder at VarnaIT Senior Developer at 158ltd.com Cleaner Code With CoffeeScript Github Code