Hey guys, did you know that JavaScript functions can have unknown arguments?
JS functions can also have optional arguments and an even optional number of arguments!
And the best part of it, is that arguments can be treated as arrays, including built-in JavaScript methods.
To explain this using a very simple example, let’s create a function,
that will sum up any numbers that are passed to it.
Try it live at JSFiddle, or simply click ‘Result’ in the form below:
Two weeks have passed since I started my JavaScript Marathon along with writing this blog!
Time to celebrate.
Just yesterday, I worked with Dates in JavaScript.
So to celebrate this day, I created a universal function, which tells you the time that has passed from any moment in the past till the present moment.
Let’s go!
Here we go. Let’s create a function, which would take any Date as an argument and return us the information on how long ago it happened:
As an additional feature, I’d like to change the Date output into European format so it is presented as dd.mm.yy hh:mm: