How to declare String Variables in JavaScript?

JavascriptWeb DevelopmentFront End Technology

JavaScript is untyped language. This means that a JavaScript variable can hold a value of any data type. To declare variables in JavaScript, you need to use the var keyword. Whether it is a string or a number, use the var keyword for declaration. 

Here’s how you can declare strings in JavaScript −

var name = “David”;
var subject = “Programming”;

You can try to run the following code to learn how to declare strings in JavaScript −

      <title>JavaScript Strings</title>
         var re = "java";
         var str = "Learn java";
         if ( == -1 ){
            document.write("Not found!" );
         } else {
            document.write("Found!" );
Published on 16-Jan-2018 11:02:36