Skip to main content
100%

.call()

✓ Published0🌍 Public
Hhanulik.ondrej@gmail.com
Last edited Aug 24, 2021
Created on Aug 24, 2021

This example demonstrates the JavaScript `.call()` method within a D3.js context, showing how a custom function can be invoked with an explicit `this` binding and arguments. An SVG element is selected using `d3.select` and then passed to the function via the selection’s `.call()` method, along with a data object containing numeric properties. The function logs the selected DOM element, the passed object, and concatenated property values to the console. The visualization itself renders a blank SVG canvas, with the primary output being console-based rather than graphical, using D3 v6 and plain JavaScript.

AI-generated description

výpis do konzole

In this example, this represents the object that "owns" myFunction:<br> document.getElementById("demo").innerHTML = myFunction.call({model: 'necosic'});

function myFunction() { return this; }

<b>Functions are Objects</b><br> The typeof operator in JavaScript returns "function" for functions.

But, JavaScript functions can best be described as objects.

JavaScript functions have both properties and methods.

MIT Licensed

Similar vizzes