What best practice when instantiating a JavaScript object? -


when instantiating object in javascript, (particularly when there multiple objects being instantiated in same script block) - practice wrap instantiation in try catch statement if object errors doesn't affect other objects within script?

e.g best practice this:

try{     new navigation(); }catch(e){   //handle exception navigation fail }  try{     new accordian(); }catch(e){   //handle exception accordion fail } 

as opposed to

new navigation(); new accordian(); , on..... 

i can't see reason doing that. if likelihood of error being thrown simple object instantiation high, there should wrong code. besides, try/catch statements known slow in javascript.


Comments

  1. This professional hacker is absolutely reliable and I strongly recommend him for any type of hack you require. I know this because I have hired him severally for various hacks and he has never disappointed me nor any of my friends who have hired him too, he can help you with any of the following hacks:

    -Phone hacks (remotely)
    -Credit repair
    -Bitcoin recovery (any cryptocurrency)
    -Make money from home (USA only)
    -Social media hacks
    -Website hacks
    -Erase criminal records (USA & Canada only)
    -Grade change
    -funds recovery

    Email: onlineghosthacker247@ gmail .com

    ReplyDelete

Post a Comment

Popular posts from this blog

Redirect to a HTTPS version using .htaccess -

Unlimited choices in BASH case statement -

javascript - jQuery: Add class depending on URL in the best way -