开发者

Javascript string performance comparison

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(开发者_如何学JAVA0, -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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜