JavaScript : Variables and Operators

Posted by ActiveEnnovations

JavaScript : Variables and Operators

            While testing the JavaScript code on your website, there will be times that you will want to write notes to yourself or temporarily remove pieces of code. If you have worked with other programming languages before, you know that most have the capability of commenting out code so that it will not be run when the program is executed.

            To comment out a piece of code in JavaScript, you will need to use one of the following two delimiters:

// anything on this line after a double forward slash becomes unprocessed code.

/* the same goes for anything between these marks. This method is preferred for blocking out large portions of code.    */

            The point of programming is to be able to hold information and manipulate values, so the basic way to do this is with variables. There are no typed variables in JavaScript, a variable is just a value holder. As opposed to being typed as a number or text value, there is just the “var” keyword.

var number = 9;

var name = “jack”;

            This also means that you must be careful when manipulating the values. As “name + number” will produce a result. In this case “jack9”. For the most part arithmetic is done by using the symbols we have all come to use in math classes:

+: Addition.  It is also used to concatenate strings. Such was the case for “jack9” above.

-:  Subtraction

*: Multiplication

/: Division

Not so much in math classes, they are based on integer math:

%: Modulus or modulo will give you the remainder of a division.  (i.e. 7  % 3= 1)

++: Increments a number by 1.(i.e. 3++ = 4) You will usually use these with counters.

--: Decrements a number by 1. Also, usually used with counters.

Posted on: 7/13/2010 at 1:04 PM
Tags: , , ,
Categories: JavaScript
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (14) | Post RSSRSS comment feed

Comments

silkroad gold United Kingdom

Wednesday, October 13, 2010 8:57 AM

silkroad gold

Such a usefule blog wow !!!!

tiffany co People's Republic of China

Wednesday, October 13, 2010 11:46 AM

tiffany co

This article gives the light in which we can observe the reality. This is very nice one and gives in-depth information

Ugg Boots From China People's Republic of China

Saturday, October 16, 2010 10:35 AM

Ugg Boots From China

This article gives the light in which we can observe the reality. This is very nice one and gives in-depth information

Ugg Bailey Button boots People's Republic of China

Saturday, October 16, 2010 12:16 PM

Ugg Bailey Button boots

This article gives the light in which we can observe the reality. This is very nice one and gives in-depth information

silkroad gold United States

Wednesday, October 20, 2010 1:33 AM

silkroad gold

something like that. Can I take part of your post to my blog?

learn penny stocks United Kingdom

Wednesday, October 20, 2010 2:12 AM

learn penny stocks

A insightful post right there mate . Thanks for that .

find ottawa dentist United States

Wednesday, October 20, 2010 2:35 AM

find ottawa dentist

I'm getting a browser error, is anyone else?

Women's Evera Boots Chestnut People's Republic of China

Wednesday, October 20, 2010 11:22 AM

Women's Evera Boots Chestnut

This article gives the light in which we can observe the reality. This is very nice one and gives in-depth information

ugg Payton Boots People's Republic of China

Wednesday, October 20, 2010 12:04 PM

ugg Payton Boots

This article gives the light in which we can observe the reality. This is very nice one and gives in-depth information

ugg Adirondack Boot II Obsidian People's Republic of China

Friday, October 22, 2010 10:15 AM

ugg Adirondack Boot II Obsidian

This article gives the light in which we can observe the reality. This is very nice one and gives in-depth information

pierscionki United States

Saturday, October 23, 2010 8:59 AM

pierscionki

Date Hello, I have browsed most of your posts. This post is probably where I got the most useful information for my research. Thanks for posting, maybe we can see more on this. Are you aware of any other websites on this subject

cloisonne vase United States

Tuesday, October 26, 2010 1:34 PM

cloisonne vase

This website is very good! How can I make one like this ?

Phone Insurance United Kingdom

Monday, November 22, 2010 9:12 PM

Phone Insurance

An interesting blog post right there mate ! Thank you for that .

TV Insurance United States

Monday, November 22, 2010 9:13 PM

TV Insurance

Please message me with some hints on how you made this website look this cool, I would appreciate it.

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading