Created
May 3, 2022 02:52
-
-
Save 1naveengiri/aecfcfaa4adf4850045c901682d10ce3 to your computer and use it in GitHub Desktop.
4 ways to define a function in javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// < 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