Working with variables is that you learn the basics regardless of the language, learn to declare them and manipulate them is essential and makes everyday stop for any programmer. Each language has a specific way of working with them, in the case of Javascript they are treated in a very simple, straightforward and objective.

To declare a variable in Javascript just use the syntax “var” then the variable name.

var v1=10;
var v2=150;

Once you declare it you can use it simply by referencing its name over the source code.

var x=30;
var y=20;

Looking at the example above, notice now one of the first peculiarities of Javascript, no need to declare a variable, just create it in the source code that automatically it can be used. Despite the convenience, this practice is not recommended anyway is very simple to get lost along the lines of code adopting this type of programming format.

Another peculiarity of the JavaScript language is that you can handle any kind of data in a single variable, check out the example below:

var v1 = 200 / / integer value worth 200
v1 = false / / turns into a variable of type boolean false
v1 = “text” / / turns into a variable of type String
v1 = 0.75 / / turns into a decimal number

When working with web programming is essential to master the JavaScript language as already commented in another post on our blog, check in the Main Programming Languages ​​for Beginners.


Want to test your code and learn more and more? Then download the free version already Scriptcase and get started programming on a WEB development tools more powerful Brazil. Check out all the advantages that our tool offers the E-Learning section, be sure to check.

You might also like…

SCRIPTCASE: What is VS What is not

What is VS What is not What is ScriptCase? It is a fast development environment with tools that f...

Conversion Process to Scriptcase 9

How to perform the conversion process to Scriptcase 9 For this Guide to perform the conversion proc...

You might also like…

Get new posts, resources, offers and more each week.

We will use the information you provide to update you about our Newsletter and Special Offers. You can unsubscribe any time you want by clinck in a link in the footer of any email you receive from us, or by contacting us at Learn more about our Privacy Police.