⊗jsPmCxCMP 440 of 504 menu

Call method with parameters in JavaScript

Now let the function func take some parameters, let's call them param1 and param2:

function func(param1, param2) { console.log(this.value + param1 + param2); }

When calling a function via call, you can pass these parameters like this:

func.call(elem, param1, param2);

Let the following code be given:

<input id="elem" value="hello"> let elem = document.querySelector('#elem'); function func(surname, name) { console.log(this.value + ', ' + name + ' ' + surname); } func(); // should output here 'hello, John Smit'

Add the call method to the last line so that 'hello, John Smit' is displayed. The word 'hello' must come from the input value, 'John' and 'Smit' must be function parameters.

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline