Thomas’ Developer Blog

March 3, 2008

Small javascript tip

Filed under: javascript — Tags: , , — sanzon @ 6:05 am

Well lately I haven’t had anything to post about since all the code i’ve been working on has been extremely mundane and quite boring.  So just so that I seem alive…

 A quick tip for javascript is to always use subfuctions!  Simply put instead of copy and pasting the code into different functions, try to create a function that can be called in the middle of another to handle those issues.

 I’m sure a lot of people already use this, but something that really annoys me is seeing repeative code.  If you see the same code more then 3 times or something close to it, chances are you’re doing something wrong!  Now there are times when it’s ok to do it. 

 The script I’m working  on now is for controlling tabs across the screen.  Really simple script but has a lot of simular code, but it would cause more work to sit there and create a code to handle it otherwise.  So at times it’s ok to copy and paste, but whenever possible avoid this!

Advertisements

3 Comments »

  1. Subfunctions rule! They’re already really useful for declaring private methods in a javascript class object.

    Comment by Jaffer Haider — March 3, 2008 @ 4:46 pm

  2. thank you, bro

    Comment by Kylerxi — March 24, 2008 @ 7:55 am

  3. I think the admin of this web page is actually working hard for his web page,
    because here every material is quality based stuff.

    Comment by how to configure best best wireless best wireless cable modem — September 8, 2014 @ 7:56 am


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: