Performance of bitwise operators in javascript

后端 未结 12 2393
难免孤独
难免孤独 2020-12-14 08:33

One of the main ideas behind using bitwise operators in languages like C++/java/C# is that they\'re extremely fast. But I\'ve heard that in javascript they\'re very slow (ad

12条回答
  •  青春惊慌失措
    2020-12-14 09:16

    Nobody uses hex anymore?

    function hextoRgb(c) {
        c = '0x' + c.substring(1);
        return [(c >> 16) & 255, (c >> 8) & 255, c & 255]; 
    }
    
    var c1 = hextoRgb('#191970');
    alert('rgb(' + c1.join(',') + ')');
    

提交回复
热议问题