Skip to content

Instantly share code, notes, and snippets.

View samnajian's full-sized avatar
🏠
Working from home

Sam Najian samnajian

🏠
Working from home
View GitHub Profile
@samnajian
samnajian / flatten_array.js
Last active July 18, 2016 08:09
Flattern array in JS
function flatten_array( arr ){
/**
* Checks if _arr is an array
* @param Array|Mixed _arr variable to check
* @return Bool whether _arr is an array
*/
const is_array = ( _arr ) => {
return typeof _arr === "object" && typeof _arr.concat === "function";
};
@samnajian
samnajian / change-svg-fill-color.js
Created September 27, 2017 15:17
Trick to change svg fill color
document.addEventListener('DOMContentLoaded', function() {
/**
* Refrence to object element that has svg as data attribute
**/
const obj = document.querySelector('object');
const svg = obj.contentDocument.querySelector("svg");
svg.style.fill = "red" // change fill color to red
}, false);