cookieceshi

Benchmark created on


Description

function readCookie(name){ var value = document.cookie.match('(?:^|;)\s' + name + '=([^;])'); return (value) ? unescape(value[1]) : null; }

Test runner

Ready to run.

Testing in
TestOps/sec
acc
function readCookie(name) {
  var value = document.cookie.match('(?:^|;)\\s*' + name + '=([^;]*)');
  return (value) ? unescape(value[1]) : null;
}
ready
aadddd
function cookie(name) {
  var cookieArray = document.cookie.split("; "); //得到分割的cookie名值对    
  var cookie = new Object();
  for (var i = 0; i < cookieArray.length; i++) {
    var arr = cookieArray[i].split("="); //将名和值分开
    //如果是指定的cookie,则返回它的值    
    if (arr[0] == name) {
      return unescape(arr[1]);
    }
  }
  return "";
}
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.