Addition and concatenation:- genius student


  • Concatenation is a joining of two or more string variables.
  • It is done by "+" operator or concat() function.
  • For two integer or double variables the "+" operator is used as arithmetic operator.
  • Code:-

  • <!DOCTYPE html> 
  • <html> 
  •  
  • <head> 
  •  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  • </head> 
  •  
  • <body> 
  •  
  •  <h1>Addition and Concatenation difference</h1> 
  •  
  •  <input type="button" onclick="fun_add();" value="Add Function"> 
  •  <input type="button" onclick="fun_conca();" value="Concatenation Function"> 
  •  
  •  <script> 
  •   /* 
  •       Concatenation mean adding two string or character, addition mean sum of two number, in the following example is explaining the difference of adding two numbers and adding one number and character. 
  •       If you put a number in inside a double or single quote the javascript is consider it as a string (not number). 
  •       */ 
  •  
  •   function fun_add() 
  •   { 
  •    alert(4 + 6); 
  •   } 
  •  
  •   function fun_conca() 
  •   { 
  •    alert(4 + "6"); 
  •  
  •   } 
  •  </script> 
  •  
  • </body> 
  •  
  • </html>
  • Addition and concatenation:- genius student Addition and concatenation:- genius student Reviewed by Network security on November 04, 2019 Rating: 5

    No comments:

    Useful Information

    Powered by Blogger.