JSFiddle - React, Tailwind, and code Playground
JavaScript
(function() { /*Script to test the performance*/
'use strict';
var t_array = [],
t_obj = {},
t_strobj = {},
test_str = "alongstringwithalongname",
isArray = function(obj) {
return (typeof(obj) === "object" && typeof(obj.length) === "number");
},
now = function() {
return new Date().getTime();
},
testArrayWrite = function(n) {
var time, i;
console.log("Testing Array Write for " + n + " numbers...");
t_array = [];
time = now();
for (i = 0; i < n; i=i+1) {
t_array[i] = i;
}
console.log("Execution Time - " + (now() - time));
},
testObjectWrite = function(n) {
var i, time;
console.log("Testing Object Write for " + n + " numbers...");
t_obj = {};
time = now();
for (i = 0; i < n; i=i+1) {
t_obj[i] = i;
}
console.log("Execution Time - " + (now() - time));
},
testObjectWrite1 = function(n) {
var str_array = [test_str],
i, j, time, len, m, tstr;
if (isArray(arguments[1])) {
str_array = arguments[1];
}
for (i = 0, len = str_array.length; i < len; i=i+1) {
tstr = str_array[i];
console.log("Testing Object String Read for " + n + " numbers with string " + tstr + "...");
time = now();
for (j = 0; j < n; j=j+1) {
t_strobj[tstr + j] = j;
}
console.log("Execution Time - " + (now() - time));
}
},
testArrayRead = function(n) {
var m, time, i;
console.log("Testing Array Read for " + n + " numbers...");
time = now();
for (i = 0; i < n; i=i+1) {
m = t_array[i];
}
...