473,394 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

javascript increment

Explain the pre increment and post increment?
what is the difference between the post increment and pre increment?
Apr 7 '10 #1
2 2506
chathura86
227 100+
this is common to the all programming languages (or at least most), not only for JS.

pre increment (++i) means the nutriment will be done before the execution of the expression,

post (i++) means increment will be done after the executing the expression;

Expand|Select|Wrap|Line Numbers
  1.     var i = 10;
  2.     document.write(i);
  3.     document.write(i++);    //post incriment -> this will print 10 and the increment the i by 1 so the i = 11
  4.     document.write(++i);    //pre incriment -> this will print 12 because i was 11 and it will be creased by 1 before printing it
  5.  
here are some links to check

http://bytes.com/topic/c/answers/506...post-increment

http://stackoverflow.com/questions/1...t-optimization

http://www.devarticles.com/c/a/JavaS...t-Operators/3/

Regards
Apr 7 '10 #2
thanks for ur reply ya
Apr 16 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

15
by: Sue Barth | last post by:
Hi all, I hope I'm in the right ng for this... I made an .asp page that allows users to toggle thru a directory of photos. The page accomplishes the following: selects a directory of photos...
2
by: Ralph Krausse | last post by:
I want to create my own kind of counter, for myself. I have a resume page on my site. I want to know how many people go there but dont want to 'go there' myself because I don't want to increase the...
8
by: Prometheus Research | last post by:
http://newyork.craigslist.org/eng/34043771.html We need a JavaScript component which will auto-submit a form after a set period has elapsed. The component must display a counter that dynamically...
3
by: Michael Kragh Pedersen | last post by:
I want to increment a ASP variable by 1, each time I click on a A HREF (by onClick). Is that at all possible in any way? Michael K. P.
5
by: psimakov | last post by:
I just read a great article by Dave Johnson on comparative performance of XML and JSON parsing. It is a very important for anyone doing AJAX. But the parsing is not the only place where CPU can...
5
by: Stuart | last post by:
Hi all, Iv'e got a page that has a mass amount of input fields, all of which require a decimal figure. To make it easier when it comes to inputting data, I'm trying to setup + and - links that...
4
by: ReGenesis0 | last post by:
Okay, this involves integrating javascript with PHP (though you don't have to know PHP to understand my question.) I have a page. It has a link. When someoen clicks on the link, iw ant to...
3
by: sunbeam | last post by:
Short Description of the Project: we developed a e-learning system for our students. each student has a unique username/password to view the modules he/she should view and nothing more. since we...
1
by: KRISHNA PRAVI | last post by:
the error is "runtime error object expected" here is the code....................................................................................... <script language="javascript"...
3
by: Rambaldi | last post by:
Although i'm working on ASP.net, i think the problem i'm facing is related to my javascript function so i hope i create the thread in the right section. My goal is to create a table dynamically,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.