Skip to content

Instantly share code, notes, and snippets.

@qwelias
qwelias / index.html
Last active March 6, 2020 15:03 — forked from mlhaufe/index.html
strict mode efficiency Array#{map,fill,reduce} (http://jsbench.github.io/#88006c73d4d180cade74f99c149bfff6) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>strict mode efficiency Array#{map,fill,reduce}</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
function escapeUI (str) {
if(!str) return str;
if(typeof str != 'string') return str;
return str.replace(/[\0\x08\x09\x1a\n\r"'\\\%]/g, function (char) {
switch (char) {
case "\0":
return "\\0";
case "\x08":
return "\\b";
case "\x09":