Skip to content

Instantly share code, notes, and snippets.

// (C) new BSD license
// fix FF bug (delay pass to function) and add support of arguments
(function($G)
{
var fnCache = {};
var _fixNoArgs = function(_origFn, _arraySlice)
{
return function(/*_fn, delay*/) // .length === 0
{
(function($G)
{
var _lengthGetter = function()
{
var b = -1;
var i;
for( ;; )
{
i = 1;
// known issues:
// 1) not cross frame (_fn.toString === Function.prototype.toString)
var _isFunction = function(_fn)
{
return typeof(_fn) == 'function' ||
(
typeof(_fn) != 'string' &&
!(_fn instanceof String) &&
String(_fn).replace(/^\s+/, '').slice(0, 8) == 'function' &&
(
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>keycode scaner</title>
<meta name="keywords" content="jbasis, keycode ,javascript, tool, tools">
<meta name="description" content="jbasis keycode scaner">
<meta content="text/html; charset=UTF-8" http-equiv="content-type">
/*
this test shows independence loop structure of performance
internal asm code become same
*/
var m = 1000
, aL = new Array(m)
;
aL[aL.length - 1] = 1;
@bga
bga / ieemu.js
Last active August 25, 2020 17:10
/*
Copyright 2006 Emil A Eklund <[email protected]> & Erik Arvidsson <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
// via me and @kangax
(function()
{
var a = {};
var someId = new Date();
var proto = {};
proto[someId] = someId;
return (a.__proto__ = proto, a[someId] === someId) &&
Array.prototype._shuffleSelf = function()
{
var i = this.length;
if(i >= 2)
{
var _rand = Math.random;
while(--i)
{
$jb._isFunction([].map) &&
(function(){
var n = 0
, isFail = false
, a = [1, 2, 3]
, b = a.map(
function(v, i, vs)
{
n |= 1 << i;
/*
es5 introduces new Object api. Object.keys returns array of own enumerable keys of object.
In es3 we have classic construction "for in hasOwnProperty" for this purposes.
Test try to find what is best - es3 enumeration or es5
In es5 we have overhead of array making and allocation
In es3 we have overhead of enumeration extra properties from prototype chain and filter it(using hasOwnProperty - extra function call)
update 1
according brilliant idea of @abozhilov (http://twitter.com/abozhilov/status/26758011447) there is 3rd way which
uses nonstandard __proto__ (presents in v8 and JagerMonkey)