Open In App

JS++ | Variables and Data Types

In this tutorial, we will introduce variables in JS++. Let’s start with an example. Create a new folder and name it “Variables”. Then create a new file and name it “Variables.jspp”. Write in the following code:

external $;
    
string firstString = "This is a string.";
int firstInt = 1;
double firstDouble = 1.1;
bool firstBool = true;

$("#string_content").text(firstString);
$("#int_content").text(firstInt);
$("#double_content").text(firstDouble);
$("#bool_content").text(firstBool);

Save Variables.jspp to your Variables folder. Then create a second file named “Variables.html” and write in the following:



<!DOCTYPE html>
<title>Variables program</title>
<body>

<p id="string_content"></p>
<p id="int_content"></p>
<p id="double_content"></p>
<p id="bool_content"></p>

<script src="http://code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="Variables.jspp.js"></script>

</body>
</html>

Save Variables.html to your Variables folder. Compile Variables.jspp and then open Variables.html in a browser. If everything has worked, your document should display the values of the four variables in Variables.jspp.

Article Tags :