ecmascript 6 - What does => mean in JavaScript? (equals greater than) -


tl;dr: => do?

i've finished solving problem on codewars , after looking @ other peoples' common responses problem, keep seeing this: =>

the problem below:

you have quiver of arrows, have been damaged. quiver contains arrows optional range information (different types of targets positioned @ different ranges), each item arrow. you need verify have ones left, in order prepare battle. below example array quiver of arrows.

anyarrows([ {range: 5},  {range: 10, damaged: true},  {damaged: true} ]) 

if arrow in quiver not have damaged status, means it's new.

this example saw returns true or false, depending on if there undamaged arrow in quiver:

function anyarrows(arrows){   return arrows.some(a => !a.damaged); } 

now, way shorter code! mine lot more basic:

function anyarrows(arrows){   ( var = 0 ; < arrows.length ; i++ ){     if ( arrows[i].damaged === false ) { return true; }     else if (arrows[i].damaged === true) { return false; }     else if (arrows[i].range === 0) { return false }     else { return true; }    }   if (arrows.length === 0) return false; } 

again though, question is: => in case , in general?

=> es2015 syntax separates arrow function parameters body, e.g. (params) => { /* body */ }.

arrowfunction : arrowparameters => concisebody


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -