Function Invocation in javascript

Something Like that:
Function Invocation

For that you need to create first html code.

HTML

<p>Value of a function =  <span id="demo1"></span></p>

After that add this JS code.

JS

//Function Invocation
function b(){
  document.getElementById("demo1").innerHTML = "Home";
}
function a(){
  document.getElementById("demo1").innerHTML = "Home2";
    b();
}
a();

[codepen_embed height=”265″ theme_id=”0″ slug_hash=”LjGQrV” default_tab=”result” user=”pradeepanvi”]See the Pen Function Invocation in javascript by Pradeep Kumar (@pradeepanvi) on CodePen.[/codepen_embed]

Now you can see

Value of a function = Home

But there is one issue I defined function a value Home2, so why it’s changed.

Because b function is calling into a function and the value has been re-write in function b, that’s why.

Leave a Reply

Your email address will not be published. Required fields are marked *