how to use JavaScript string?


  • JavaScript strings are used for storing and manipulating text.
  • A JavaScript string simply stores a series of characters like "Merbin Joe".
  • A string can be any text inside quotes. You can use single or double quotes.



  • Code:- 


  • <!DOCTYPE html> 
  • <html> 
  •  
  • <head> 
  •  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  • </head> 
  •  
  • <body> 
  •  
  •  <h1>JavaScript Strings</h1> 
  •  
  •  <div id="d1"></div> 
  •  <div id="d2"></div> 
  •  
  •  <input type="button" onclick="cal_str();" value="call fun"> 
  •  
  •  <script> 
  •   function cal_str() 
  •   { 
  •    /*String are written in double or single quotes*/ 
  •    document.getElementById("d1").innerHTML = 'This is in single quote'; 
  •    document.getElementById("d2").innerHTML = "This is in Double quote"; 
  •   } 
  •  </script> 
  •  
  • </body> 
  •  
  • </html>
  • how to use JavaScript string? how to use JavaScript string? Reviewed by Network security on June 01, 2019 Rating: 5

    No comments:

    Useful Information

    Powered by Blogger.