Basic of Function in js
function hello()
{
console.log("hello")
}
hello()
With parameters
function hello(name,message)
{
console.log(`hello ${name} ${message}`)
}
hello("Dev","Welcome")
With return
If we want the function to return the procesed value return is used
A function can contain only one return
function hello(name,message)
{
return `hello ${name} ${message}`
}
console.log(hello("Dev","Welcome"))
With Arrow Function (ES6)
const hello = () => {
return `hello ${name} ${message}`
}
console.log(hello("Dev","Welcome"))
Top comments (0)