xxxxxxxxxx
function sayHello() {
return "Hello, ";
}
function greeting(helloMessage, name) {
console.log(helloMessage() + name);
}
// Pass `sayHello` as an argument to `greeting` function
greeting(sayHello, "JavaScript!");
// Hello, JavaScript!
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
const bankInfo = {
name: 'ING',
address: '79 Strasse',
city: 'Amsterdam',
country: 'Europe'
}
console.log(bankInfo['name']) //the key name is ING
// use `in` within a conditional
if('address' in bankInfo){
console.log('result: ', bankInfo['address'])
}
//will print result: 79 Strasse
//remember to use quotes around the key
xxxxxxxxxx
function map(f, a) {
const result = new Array(a.length);
for (let i = 0; i < a.length; i++) {
result[i] = f(a[i]);
}
return result;
}