DeveloperBreeze

Javascript This Development Tutorials, Guides & Insights

Unlock 1+ expert-curated javascript this tutorials, real-world code snippets, and modern dev strategies. From fundamentals to advanced topics, boost your javascript this skills on DeveloperBreeze.

Understanding call, apply, and bind in JavaScript

Tutorial August 30, 2024
javascript

function greet(greeting, punctuation) {
    console.log(greeting + ' ' + this.name + punctuation);
}

const person = { name: 'Alice' };

greet.call(person, 'Hello', '!');  // Output: "Hello Alice!"

In this example, greet is called with person as the this value, and 'Hello' and '!' as arguments. The this inside the greet function refers to person.