Skip to content

Instantly share code, notes, and snippets.

cian6390

Block or report user

Report or block cian6390

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@cian6390
cian6390 / getUrlVars.js
Last active May 21, 2016
JavaScript get url parameter with decode
View getUrlVars.js
function getUrlVars() {
var url = decodeURIComponent(window.location.href);
var vars = {};
var hashes = url.split("?")[1];
var hash = hashes.split('&');
for (var i = 0; i < hash.length; i++) {
params = hash[i].split("=");
vars[params[0]] = params[1];
@cian6390
cian6390 / flatObj.js
Last active May 21, 2016
JavaScript Object Flatten
View flatObj.js
function flatObj(obj) {
if (!obj || typeof obj !== 'object' || obj instanceof Array) {
throw new TypeError('flatObj() arguments need be object');
}
var result = {};
for (var x in obj) {
if (obj[x] && typeof obj[x] === 'object') {
for (var y in obj[x]) {
result[x + '_' + y] = obj[x][y];
}
You can’t perform that action at this time.