Skip to content

Instantly share code, notes, and snippets.

@1naveengiri
Created May 3, 2022 02:52
Show Gist options
  • Save 1naveengiri/aecfcfaa4adf4850045c901682d10ce3 to your computer and use it in GitHub Desktop.
Save 1naveengiri/aecfcfaa4adf4850045c901682d10ce3 to your computer and use it in GitHub Desktop.
4 ways to define a function in javascript
// < ES5
function x( n1, n2 ){
return n1 + n2;
}
console.log(x(9,2));
// ES5
var y = function(n1, n2){
return n1 + n2;
}
console.log(y(10,2));
// ES6
const z = (n1, n2) =>{
return n1 + n2;
};
console.log(z(11,3));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment