JSFiddle - React, Tailwind, and code Playground
by sharon li
JavaScript
var jQuery = function(selector, context) {
return new jQuery.fn.init(selector, context);
};
jQuery.fn = jQuery.prototype = {
init : function(selector, context) {
}
};
/**
* if obj is plain object
*/
jQuery.isPlainObject = function(obj) {
if (typeof obj === 'object' &&
!(obj instanceof Function))
{
return true;
}
else
return false;
}
/**if obj is undefined, because the undefined can be rewrite so need to typeof
*/
jQuery.isUndefined = function(obj) {
if (obj === undefined &&
typeof undefined === 'undefined') {
return true;
}
else {
return false;
}
}
jQuery.isNull = function(obj) {
if (obj === null) {
return true;
}
else {
return false;
}
}
/**
* if obj is plain array
*/
jQuery.isPlainArray = function(obj) {
if (typeof obj === 'object' &&
typeof obj.length === 'number' &&
typeof obj.splice === 'function'
) {
return true;
}
else {
return false
}
}
/**
* if obj is function
*/
jQuery.isFunction = function(obj) {
if (typeof args === 'object' &&
args instanceof Function) {
return true;
}
else
return false;
}
/**
[deep] , target, object1 ... objectN
target, object1 ... objectN
*/
jQuery.extend = jQuery.fn.extend = function() {
var target;
var deep = false;
if (argument.length) {
target = arguments[0];
if (typeof target === 'boolean') {
deep = true;
if (arguments.length > 2) {
target = arguemnts[1];
for(var i=2;i< arguments.length;i++) {
var args = arguments[i];
//undefined and null type, skip it
if (jQuery.isUndefined(args) || jQuery.isNull(args)) {
continue;
}
//js primary type
if...