JavaScript mendefinisikan fungsi
function nameFunction(parameters) {
document.write("function script")
}
Rick Astley
function nameFunction(parameters) {
document.write("function script")
}
// Five examples of non-arrow function expressions
function (x) { return x + x + x }
function (s, n) { return s.length > n }
function (p, n, r, t) { return p * Math.pow(1 + (r / n), n * t) }
function () { return Math.random() * 100 }
function (x, y) {
let xSquared = x * x
let ySquared = y * y
return Math.sqrt(xSquared + ySquared)
}
function myFunction(var1, var2) {
return var1 * var2;
}
<div class="alert alert-warning alert-dismissible fade show" role="alert">
<strong>Holy guacamole!</strong> You should check in on some of those fields below.
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
function MyFunction() {
/* Function Here */
}
function myfunction(p1,p2){
return p1+p2 // للجمع بين القيمتان
}
var p = document.getElementById("tst");
p.innerHTML=myfunction(10,20) // النتيجة 30