| FazBrowse Wikipedia Viewer | Main Page | | |
| Viewing: https://en.wikipedia.org/wiki/CoffeeScript |
| CoffeeScript | ||
|---|---|---|
| Paradigms | Multi-paradigm: prototype-based, functional, imperative, scripting | |
| Family | ECMAScript | |
| Designed by | Jeremy Ashkenas | |
| Developer | Same | |
| First appeared | December 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:
| ||