xxxxxxxxxx
//passing a function as param and calling that function
function goToWork(myCallBackFunction) {
//do some work here
myCallBackFunction();
}
function refreshPage() {
alert("I should be refreshing the page");
}
goToWork(refreshPage);
xxxxxxxxxx
public interface MyInterface {
String doSomething(int param1, String param2);
}
class MyClass {
public MyInterface myInterface = (p1, p2) -> { return p2 + p1; };
}
new Thread(this::someMethod).start();
xxxxxxxxxx
// program to print the text
// declaring a function
function greet(name) {
console.log("Hello " + name + ":)");
}
// variable name can be different
let name = prompt("Enter a name: ");
// calling function
greet(name);
xxxxxxxxxx
/* DEFINATION: Function parameters are the variables specified in the function
definition, and function arguements are the values passed as arguements.*/
//code:
function saySomething(phrase){
console.log("You said: "+ phrase)
}
saySomething("Hello how are you?")
xxxxxxxxxx
<body>
<h1>Passing parameter from html to javascript function</h1>
<button onclick="myFunction()">Add</button>
<script>
function myFunction(para1) {
alert("parameter is ",para1);
}
</script>
</body>