FazBrowse Wikipedia Viewer | Main Page |
Search Wikipedia:
|
Viewing: https://en.wikipedia.org/wiki/CoffeeScript

CoffeeScript

.coffee</code>, <code>.litcoffee</code>{{citation needed|date=September 2020}}"},"influenced by":{"wt":"[[Haskell]], [[JavaScript]], [[Perl]],{{citation needed|date=January 2016}} [[Python (programming language)|Python]],<ref>https://coffeescript.org/ \"CoffeeScript borrows chained comparisons from Python\"</ref> [[Ruby (programming language)|Ruby]], [[YAML]]<ref name=\"smell\">{{cite news |last1=Heller |first1=Martin |date=2011-10-18 |df=mdy |url=https://www.infoworld.com/article/2078452/turn-up-your-nose-at-dart-and-smell-the-coffeescript.html |title=Turn up your nose at Dart and smell the CoffeeScript |work=[[InfoWorld]] |access-date=2020-07-15}}</ref>"},"influenced":{"wt":"[[MoonScript]], [[LiveScript (programming language)|LiveScript]], JavaScript"}},"i":0}}]}'>
CoffeeScript
ParadigmsMulti-paradigm: prototype-based, functional, imperative, scripting
FamilyECMAScript
Designed byJeremy Ashkenas
DeveloperSame
First appearedDecember 13, 2009;16 years ago (2009-12-13)
letmass=72; letheight=1.78; letBMI=mass/height**2; if(18.5<=BMI&&BMI<25)alert('You are healthy!');

With CoffeeScript the interval is directly described:

gcd=(x, y) -> [x,y]=[y,x%y]untilyis0 x

The ? keyword quickly checks if a variable is null or undefined :

\n if not person? then alert(\"No person\") else alert(\"Have person\")\nperson = null\npersonCheck()\nperson = \"Ivan\"\npersonCheck()\n"}}'>personCheck=-> ifnotperson?thenalert("No person")elsealert("Have person") person=null personCheck() person="Ivan" personCheck()

This would alert "No person" if the variable is null or undefined and "Have person" if there is something there.

A common pre-ES6 JavaScript snippet using the jQuery library is:


View original on Wikipedia | Back | FazBrowse Home