Skip to content

Instantly share code, notes, and snippets.

View guzmanfg's full-sized avatar

Guzmán Fernández García guzmanfg

  • Plain Concepts
  • Alicante, Spain
View GitHub Profile
@guzmanfg
guzmanfg / parseBool.js
Last active July 1, 2024 00:12
Parse boolean values (accepts any truthy or falsy values)
function parseBool (value){
var isEmptyString = (typeof value === "string" && value.length <= 0);
var isFalsy = typeof value === "undefined" || isEmptyString;
return !isFalsy && !!JSON.parse(value);
};
@guzmanfg
guzmanfg / clone.js
Last active September 14, 2016 11:36
Clone function
function clone(obj) {
var ctr = Object.getPrototypeOf(obj).constructor;
return Object.assign(new ctr(), obj);
}