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;
z=x+y;

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.

javascript

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…

PROCESAMIENTO AJAX EN SCRIPTCASE

Ajax en los formularios de Scriptcase puede usarse para recargar un campo de tipo de select basado e...

IMPORTAR IMAGENES DE LA BASE DE DATOS Y UTILIZAR CLASES DE BOOSTRAP

Como muchas personas ya saben, Bootstrap es una biblioteca de front-end libre y de código abierto p...

TENDENCIAS DE DESARROLLO WEB PARA 2017

Usted verá en este post tendencias para 2017 en Diseño Web, en el medio digital y en el desarrollo...

Comment this post

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 sales@scriptcase.net. Learn more about our Privacy Police.