justin = { main feed , music , code , askjf , pubkey };
Ask Justin Frankel
No reasonable question unanswered since 2009!

Suggested topics: programming, music, sleep, coffee, etc.

Note: please do not ask questions about REAPER features, bugs or scheduling, use the forums instead.


Name: Ask: Human (enter yes):
[back to index] | [unreplied] | [replied] | [recent comments] | [all]

Question: How would YOU write(syntactically) a simple add(a + b) function in JavaScript?
Asked by musicalcode (136.226.74.x) on October 18 2022, 4:24am
Reply on October 18 2022, 2:02pm:
    you mean?
    function add(a,b) {
      return a+b;
    }
    


Comments:
  • Posted by musicalcode (136.226.74.x) on October 19 2022, 2:46am:
    I did :) But just to see if it were that or:const add = function (a, b) { return a+b;};orconst add = (a, b) => a + b;Or, another way. "add" aside, I write the latter arrow style most often these days. Curious if you find too terse or just, whatever. I do see benefits to having "function" there for quick recognition when visually scanning lines. I guess it's like same chord/different voicing, or same voicing just on different strings :)

  • Posted by musicalcode (136.226.74.x) on October 19 2022, 2:52am:
    Sorry, tried to format as multiline, no luck.


Comment:
    Your Name:   -- Site Owner's Name:  (for human-verification)

    Comment:    

    
  
[back to index] | [unreplied] | [replied] | [recent comments] | [all]
Copyright 2024 Justin Frankel. | RSS