Go Back   Webmaster Malaysia Forum » Website Design & Development » Website Design

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 13-02-2003, 01:31 PM
Novice Webmaster
 
Join Date: Feb 2003
Location: Bandar Tasik Selatan, Malaysia
Posts: 25
Rep Power: 0
ngaisteve1 is on a distinguished road
Just some questions about Javascript

More question about javascript syntax:
1. Should I put else or not?

if (tmpWeight <= 0.5)
{
tmpTotalPrice = '6';
}
{
tmpTotalPrice = 6 + (parseInt((tmpWeight * 10) - 5));
}

if (tmpWeight <= 0.5)
{
tmpTotalPrice = '6';
}
else
{
tmpTotalPrice = 6 + (parseInt((tmpWeight * 10) - 5));
}

2. Why I see most javascript indention not too readable?

the open curly bracket is at the end of the condition
like
if (tmpWeight <= 0.5) {
...
}
instead of
if (tmpWeight <= 0.5)
{
...
}

3. Should we put semicolon at the end of the statement? I think put or not put also no difference.

4. if a > 1 and if (a > 1) got difference? I think bracket is being used when we want to prioritise certain condition only or that is a syntax.

Just hope to get Javascript more clearer. Thanks.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 13-02-2003, 04:08 PM
kpyew's Avatar
Senior Webmaster
 
Join Date: Jul 2001
Location: KL, Malaysia
Posts: 277
Rep Power: 94
kpyew is on a distinguished road
Send a message via ICQ to kpyew
1. Use else. Without else, the computer will do the unnecessary processing everytime.

2. This is individual preference. I always put the open bracket on the same line to have less lines, shorter page length.

3. I always put semicolon.

4. I always put brackets for if-else condition. Will it always work if we obmit the brackets? No idea, never test before.
__________________
webmaster @ http://kongtechnology.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
May I ask some questions related AdSense? AngelLee Revenue and Monetization 4 24-08-2006 06:50 PM
Questions on PayPal stephen E-Commerce 4 06-09-2005 11:25 PM
A few questions regarding mambo & hosting mfarid Paid Hosting Discussion Forum 7 09-03-2005 06:19 PM
How To Answer TOUGH Interview Questions Gundam Mamak Stall 0 20-02-2005 11:58 AM
questions on Sound Object in Flash denian Website Design 3 31-01-2003 02:47 PM



All times are GMT +8. The time now is 03:09 PM. Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0 vBulletin skin by ForumMonkeys.com.


WebmasterMalaysia.com is Proudly Hosted by Exabytes Semi Dedicated Server.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59