This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
VALOR COERCIÓN | |
------- --------- | |
false false | |
0 false | |
“” false | |
NaN false | |
null false | |
undefined false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//definimos el constructor del objeto base y | |
//establecemos las propiedades por instancia | |
function Person (name, age) { | |
"use strict"; | |
this.name = name || "unnamed"; | |
this.age = +age || 0; | |
} | |
//definimos el prototipo del objeto base | |
//estableciendo las propiedades compartidas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Important! | |
* This snippet is deprecated, a best implementation of sortBy can be found here: | |
* https://github.com/jherax/array-sort-by | |
*/ | |
var sortBy = (function () { | |
var toString = Object.prototype.toString, | |
// default parser function | |
parse = function (x) { return x; }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
//verificamos cual es el ámbito global | |
//(generalmente el objeto window) | |
console.log("Global scope", this); | |
var x = 42; //variable local | |
var point = { x: 10, y: 15 }; //objeto local | |
//si no se especifica el keyword "var", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//utility to create safe namespaces | |
function createNS (namespace) { | |
var nsparts = namespace.toString().split("."), | |
reName = (/^[A-Za-z_]\w+/), | |
cparent = window, | |
i, subns, nspartsLength; | |
// we want to be able to include or exclude the root namespace so we strip it if it's in the namespace | |
if (nsparts[0] === "window") nsparts = nsparts.slice(1); | |
// loop through the parts and create a nested namespace if necessary | |
for (i = 0, nspartsLength = nsparts.length; i < nspartsLength; i += 1) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Creates user-defined exceptions | |
var CustomError = (function() { | |
'use strict'; | |
//constructor | |
function CustomError() { | |
//enforces 'new' instance | |
if (!(this instanceof CustomError)) { | |
return new CustomError(arguments); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable no-underscore-dangle */ | |
/** | |
* Supported types | |
*/ | |
const TYPES = { | |
_true: /^true$/i, | |
_false: /^false$/i, | |
_null: /^null$/i, | |
_number: /^[0-9]+$/, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @author | |
* David Rivera (jherax) | |
* https://github.com/jherax | |
*/ | |
/* eslint-disable no-bitwise */ | |
/** @private */ | |
const toString = Object.prototype.toString; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Gets all event-handlers from a DOM element. | |
* Events with namespace are allowed. | |
* | |
* @param {Element} node: DOM element | |
* @param {String} eventns: (optional) name of the event/namespace | |
* @return {Object} | |
*/ | |
function getEventHandlers(element, eventns) { | |
const $ = window.jQuery; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function ($) { | |
// Reverses the array of matched elements | |
$.fn.reverse = Array.prototype.reverse; | |
/** | |
* Centers an element relative to another. | |
* @signature: $(selector).center(options) | |
* @param {Object} options: | |
* Defines the options with the following properties: |
OlderNewer