Skip to content

Instantly share code, notes, and snippets.

var Fruit = ["Apple", "Kinnow", "Mango", "Orange"];
var Citrus = ["Lemon", "Kinnow", "Orange", "Tangerine"];
function diffArrays (A, B) {
var strA = ":" + A.join("::") + ":";
var strB = ":" + B.join(":|:") + ":";
var reg = new RegExp("(" + strB + ")","gi");
var strDiff = strA.replace(reg,"").replace(/^:/,"").replace(/:$/,"");
// original (http://html5shiv.googlecode.com/svn/trunk/html5.js)
(function(){if(!/*@cc_on!@*/0)return;var e = "abbr,article,aside,audio,canvas,datalist,details,figure,figcaption,footer,header,hgroup,mark,menu,meter,nav,output,progress,section,summary,time,video".split(','),i=e.length;while(i--){document.createElement(e[i])}})()
// kangax version (29 characters less, yay!)
/*@cc_on(function(e,i){i=e.length;while(i--)document.createElement(e[i])})("abbr,article,aside,audio,canvas,datalist,details,eventsource,figure,footer,header,hgroup,mark,menu,meter,nav,output,progress,section,time,video".split(','))@*/
// jdalton version (was 5, now 41 characters less than kangax, yay!)
[] == false; // true
"" == false; // true
null == false; // false, that's more like it
var a = [];
if (a) {
alert(1); // alert this; in condition need check a.length
} else {
alert(2);
}
(function(){
this.__defineGetter__("__FILE__", function() {
return (new Error).stack.split("\n")[2].split("@")[1].split(":").slice(0,-1).join(":");
});
})();
// Array Remove - By John Resig (MIT Licensed)
Array.prototype.remove = function(from, to) {
var rest = this.slice((to || from) + 1 || this.length);
this.length = from < 0 ? this.length + from : from;
return this.push.apply(this, rest);
};
/* by Dmitry A. Soshnikov */
var object = (function () {
// private
var _x = 10;
// also private
function _privateFunc() {
return _x;
/**
* Aliases and additional "sugar"
* 2010-04-15
* @author Dmitry A. Soshnikov
*/
(function () {
["defineProperty", "defineProperties", "keys", "getOwnPropertyNames",
"getOwnPropertyDescriptor", "getPrototypeOf", "seal", "freeze",
"preventExtensions", "isFrozen", "isSealed", "isExtensible"]
if (!window.localStorage || !window.sessionStorage) (function () {
var Storage = function (type) {
function createCookie(name, value, days) {
var date, expires;
if (days) {
date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
expires = "; expires="+date.toGMTString();
/*
* classList.js
*
* Implements a cross-browser element.classList getter.
*
*/
"use strict";
if (typeof Element !== "undefined") {
var _restoreSymbol = (function($G)
{
var iframe = document.createElement('iframe');
(document.body || document.documentElement).appendChild(iframe);
iframe.style.display = 'none';
var win = iframe.contentWindow, doc = win.document;
doc.open();