is it ok to use succinct arrow function syntax if I'm not returning a value? [closed]












0














Let's say I have the function pageScroller that doesn't return any value.
Given that the succinct ES6 arrow function syntax implicitly returns the value, is it correct still ok to use it without block around?



const goToPage = pageNumber => pageScroller(pageNumber)


or I should always prefer the explicit block instead? I.e.:



const goToPage = pageNumber => {
pageScroller(pageNumber)
}


My only worrying is that people reading the code can expect that pageScroller returns a value. What do you think?










share|improve this question















closed as primarily opinion-based by charlietfl, Quentin, Mark Meyer, Liam, Patrick Roberts Nov 14 '18 at 16:28


Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.











  • 5




    Why not const goToPage = pageScroller; ? But actually thats quite opinion based.
    – Jonas Wilms
    Nov 14 '18 at 16:18






  • 1




    Technically every JavaScript function returns a value. In most cases it's undefined.
    – amphetamachine
    Nov 14 '18 at 16:19










  • This is very much a matter of opinion
    – Quentin
    Nov 14 '18 at 16:19


















0














Let's say I have the function pageScroller that doesn't return any value.
Given that the succinct ES6 arrow function syntax implicitly returns the value, is it correct still ok to use it without block around?



const goToPage = pageNumber => pageScroller(pageNumber)


or I should always prefer the explicit block instead? I.e.:



const goToPage = pageNumber => {
pageScroller(pageNumber)
}


My only worrying is that people reading the code can expect that pageScroller returns a value. What do you think?










share|improve this question















closed as primarily opinion-based by charlietfl, Quentin, Mark Meyer, Liam, Patrick Roberts Nov 14 '18 at 16:28


Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.











  • 5




    Why not const goToPage = pageScroller; ? But actually thats quite opinion based.
    – Jonas Wilms
    Nov 14 '18 at 16:18






  • 1




    Technically every JavaScript function returns a value. In most cases it's undefined.
    – amphetamachine
    Nov 14 '18 at 16:19










  • This is very much a matter of opinion
    – Quentin
    Nov 14 '18 at 16:19
















0












0








0







Let's say I have the function pageScroller that doesn't return any value.
Given that the succinct ES6 arrow function syntax implicitly returns the value, is it correct still ok to use it without block around?



const goToPage = pageNumber => pageScroller(pageNumber)


or I should always prefer the explicit block instead? I.e.:



const goToPage = pageNumber => {
pageScroller(pageNumber)
}


My only worrying is that people reading the code can expect that pageScroller returns a value. What do you think?










share|improve this question















Let's say I have the function pageScroller that doesn't return any value.
Given that the succinct ES6 arrow function syntax implicitly returns the value, is it correct still ok to use it without block around?



const goToPage = pageNumber => pageScroller(pageNumber)


or I should always prefer the explicit block instead? I.e.:



const goToPage = pageNumber => {
pageScroller(pageNumber)
}


My only worrying is that people reading the code can expect that pageScroller returns a value. What do you think?







javascript ecmascript-6 arrow-functions code-readability






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 16:20









Patrick Roberts

19.4k33475




19.4k33475










asked Nov 14 '18 at 16:16









Valerio Leo

31




31




closed as primarily opinion-based by charlietfl, Quentin, Mark Meyer, Liam, Patrick Roberts Nov 14 '18 at 16:28


Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.






closed as primarily opinion-based by charlietfl, Quentin, Mark Meyer, Liam, Patrick Roberts Nov 14 '18 at 16:28


Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 5




    Why not const goToPage = pageScroller; ? But actually thats quite opinion based.
    – Jonas Wilms
    Nov 14 '18 at 16:18






  • 1




    Technically every JavaScript function returns a value. In most cases it's undefined.
    – amphetamachine
    Nov 14 '18 at 16:19










  • This is very much a matter of opinion
    – Quentin
    Nov 14 '18 at 16:19
















  • 5




    Why not const goToPage = pageScroller; ? But actually thats quite opinion based.
    – Jonas Wilms
    Nov 14 '18 at 16:18






  • 1




    Technically every JavaScript function returns a value. In most cases it's undefined.
    – amphetamachine
    Nov 14 '18 at 16:19










  • This is very much a matter of opinion
    – Quentin
    Nov 14 '18 at 16:19










5




5




Why not const goToPage = pageScroller; ? But actually thats quite opinion based.
– Jonas Wilms
Nov 14 '18 at 16:18




Why not const goToPage = pageScroller; ? But actually thats quite opinion based.
– Jonas Wilms
Nov 14 '18 at 16:18




1




1




Technically every JavaScript function returns a value. In most cases it's undefined.
– amphetamachine
Nov 14 '18 at 16:19




Technically every JavaScript function returns a value. In most cases it's undefined.
– amphetamachine
Nov 14 '18 at 16:19












This is very much a matter of opinion
– Quentin
Nov 14 '18 at 16:19






This is very much a matter of opinion
– Quentin
Nov 14 '18 at 16:19














1 Answer
1






active

oldest

votes


















0














This is largely opinion based but you're not wrong to want to be cautious about other people thinking you might be trying to assign a value.



I'd recommend looking at the code again after a couple weeks of working with something else and see if you recognize what it's doing immediately. Also, think about if the goToPage const will ever need to do anything other than call the pageScroller. If there's any chance it would, you might be better off calling the explicit block. If there isn't, maybe see if you can just call pageScroller directly instead of using a const?






share|improve this answer




























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    This is largely opinion based but you're not wrong to want to be cautious about other people thinking you might be trying to assign a value.



    I'd recommend looking at the code again after a couple weeks of working with something else and see if you recognize what it's doing immediately. Also, think about if the goToPage const will ever need to do anything other than call the pageScroller. If there's any chance it would, you might be better off calling the explicit block. If there isn't, maybe see if you can just call pageScroller directly instead of using a const?






    share|improve this answer


























      0














      This is largely opinion based but you're not wrong to want to be cautious about other people thinking you might be trying to assign a value.



      I'd recommend looking at the code again after a couple weeks of working with something else and see if you recognize what it's doing immediately. Also, think about if the goToPage const will ever need to do anything other than call the pageScroller. If there's any chance it would, you might be better off calling the explicit block. If there isn't, maybe see if you can just call pageScroller directly instead of using a const?






      share|improve this answer
























        0












        0








        0






        This is largely opinion based but you're not wrong to want to be cautious about other people thinking you might be trying to assign a value.



        I'd recommend looking at the code again after a couple weeks of working with something else and see if you recognize what it's doing immediately. Also, think about if the goToPage const will ever need to do anything other than call the pageScroller. If there's any chance it would, you might be better off calling the explicit block. If there isn't, maybe see if you can just call pageScroller directly instead of using a const?






        share|improve this answer












        This is largely opinion based but you're not wrong to want to be cautious about other people thinking you might be trying to assign a value.



        I'd recommend looking at the code again after a couple weeks of working with something else and see if you recognize what it's doing immediately. Also, think about if the goToPage const will ever need to do anything other than call the pageScroller. If there's any chance it would, you might be better off calling the explicit block. If there isn't, maybe see if you can just call pageScroller directly instead of using a const?







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 14 '18 at 16:28









        Thorin Jacobs

        27019




        27019















            Popular posts from this blog

            鏡平學校

            ꓛꓣだゔៀៅຸ໢ທຮ໕໒ ,ໂ'໥໓າ໼ឨឲ៵៭ៈゎゔit''䖳𥁄卿' ☨₤₨こゎもょの;ꜹꟚꞖꞵꟅꞛေၦေɯ,ɨɡ𛃵𛁹ޝ޳ޠ޾,ޤޒޯ޾𫝒𫠁သ𛅤チョ'サノބޘދ𛁐ᶿᶇᶀᶋᶠ㨑㽹⻮ꧬ꧹؍۩وَؠ㇕㇃㇪ ㇦㇋㇋ṜẰᵡᴠ 軌ᵕ搜۳ٰޗޮ޷ސޯ𫖾𫅀ल, ꙭ꙰ꚅꙁꚊꞻꝔ꟠Ꝭㄤﺟޱސꧨꧼ꧴ꧯꧽ꧲ꧯ'⽹⽭⾁⿞⼳⽋២៩ញណើꩯꩤ꩸ꩮᶻᶺᶧᶂ𫳲𫪭𬸄𫵰𬖩𬫣𬊉ၲ𛅬㕦䬺𫝌𫝼,,𫟖𫞽ហៅ஫㆔ాఆఅꙒꚞꙍ,Ꙟ꙱エ ,ポテ,フࢰࢯ𫟠𫞶 𫝤𫟠ﺕﹱﻜﻣ𪵕𪭸𪻆𪾩𫔷ġ,ŧآꞪ꟥,ꞔꝻ♚☹⛵𛀌ꬷꭞȄƁƪƬșƦǙǗdžƝǯǧⱦⱰꓕꓢႋ神 ဴ၀க௭எ௫ឫោ ' េㇷㇴㇼ神ㇸㇲㇽㇴㇼㇻㇸ'ㇸㇿㇸㇹㇰㆣꓚꓤ₡₧ ㄨㄟ㄂ㄖㄎ໗ツڒذ₶।ऩछएोञयूटक़कयँृी,冬'𛅢𛅥ㇱㇵㇶ𥄥𦒽𠣧𠊓𧢖𥞘𩔋цѰㄠſtʯʭɿʆʗʍʩɷɛ,əʏダヵㄐㄘR{gỚṖḺờṠṫảḙḭᴮᵏᴘᵀᵷᵕᴜᴏᵾq﮲ﲿﴽﭙ軌ﰬﶚﶧ﫲Ҝжюїкӈㇴffצּ﬘﭅﬈軌'ffistfflſtffतभफɳɰʊɲʎ𛁱𛁖𛁮𛀉 𛂯𛀞నఋŀŲ 𫟲𫠖𫞺ຆຆ ໹້໕໗ๆทԊꧢꧠ꧰ꓱ⿝⼑ŎḬẃẖỐẅ ,ờỰỈỗﮊDžȩꭏꭎꬻ꭮ꬿꭖꭥꭅ㇭神 ⾈ꓵꓑ⺄㄄ㄪㄙㄅㄇstA۵䞽ॶ𫞑𫝄㇉㇇゜軌𩜛𩳠Jﻺ‚Üမ႕ႌႊၐၸဓၞၞၡ៸wyvtᶎᶪᶹစဎ꣡꣰꣢꣤ٗ؋لㇳㇾㇻㇱ㆐㆔,,㆟Ⱶヤマފ޼ޝަݿݞݠݷݐ',ݘ,ݪݙݵ𬝉𬜁𫝨𫞘くせぉて¼óû×ó£…𛅑הㄙくԗԀ5606神45,神796'𪤻𫞧ꓐ㄁ㄘɥɺꓵꓲ3''7034׉ⱦⱠˆ“𫝋ȍ,ꩲ軌꩷ꩶꩧꩫఞ۔فڱێظペサ神ナᴦᵑ47 9238їﻂ䐊䔉㠸﬎ffiﬣ,לּᴷᴦᵛᵽ,ᴨᵤ ᵸᵥᴗᵈꚏꚉꚟ⻆rtǟƴ𬎎

            Why https connections are so slow when debugging (stepping over) in Java?