views:

47

answers:

1

I am working on a jQuery/Javascript app where performance is really important. What would be the fastest way in getting a number value from the following code? Is the same execution time for each cases or does it matter?

//Case 1
var number = $("#someID").css("left").slice(0, -2)/100; // Returns a number

//Case 2
var number= new String($("#someID").css("left").slice(0, -2)/100); // Returns a number

//Case 3
var number = $("#someID").css("left").slice(0, -2)/100;
var number = new String(number); // Returns a number

Thank you

+1  A: 

Use the profiling functionality of Firebug to find the hotspots, and which solution is the fastest.

Sjoerd