Arrow Functions (JavaScript)
With this method, we can define anonymous function expressions in a short way. Example: var collection = (x, y) => x + y; document.write(collection(3,7)) Output: 10 Same as above example: var collection = function (x, y) { return x + y; }; document.write(collection(3,7)) As seen, the function expression is defined with a shorter method. The... Continue Reading →
javaScript DOM Navigation
With HTML DOM, all nodes in the node tree can be accessed with JavaScript. New nodes can be created and all nodes can be changed or deleted. Node Relationships The nodes in the node tree have a hierarchical relationship with each other.Parents, children and siblings are used to describe relationships. In a node tree, the... Continue Reading →
JavaScript Rest Parameters
When declaring the parameters of a function, the three-point and a parameter declared with a name give all the parameter values as an array, except the parameters that were previously reported to the function. These are called rest (all other parameters) parameters. function exam(...param) { document.write(param.length+"<br>"); } exam(0); exam(1, 2); exam(1,2,3,4,5); output: 1 , 2... Continue Reading →
Object Inside Function
JavaScript object properties can also be defined as functions and is a widely used way. var calculate = { collection: function (n1, n2) { return n1 + n2; }, extraction: function (n1, n2) { return n1 - n2; }, pow: function (n1, n2) { return n1 * n2; }, division: function (n1, n2) { return... Continue Reading →
Recursion of the function.
As with most programming languages, JavaScript functions can call themselves. However, in this case, it is also necessary to establish a control mechanism that will finish the job of calling itself in one place. Otherwise, we receive a stack overflow error when the function calls itself too much. example: function write(dat) { if (dat >... Continue Reading →