Function Call Method

Invoke a function with a specific this context using call.

Preview

Code

<script>
function greet(){
  console.log("Hello " + this.name);
}

let user = {name:"Alice"};

greet.call(user);
</script>

More JS Functions Examples (7)