Skip to content

Instantly share code, notes, and snippets.

🚀
Learning

teal-front

🚀
Learning
Block or report user

Report or block teal-front

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
View gist:1fd6e9f159822b55f218eed138c66041
function getDomPath(el) {
var stack = [];
while ( el.parentNode != null ) {
console.log(el.nodeName);
var sibCount = 0;
var sibIndex = 0;
for ( var i = 0; i < el.parentNode.childNodes.length; i++ ) {
var sib = el.parentNode.childNodes[i];
if ( sib.nodeName == el.nodeName ) {
if ( sib === el ) {
View ES6.md
View precision-add.js
/**
* Precision add function
* support e
*/
function add(num1, num2) {
const [l1, l2] = [num1, num2].map(num => {
const eSplit = num.toString().split(/e/i)
const len = (eSplit[0].split('.')[1] || '').length - (+(eSplit[1] || 0));
return Math.max(len, 0)
})
@teal-front
teal-front / 1-promise.js
Created Jun 5, 2018 — forked from primaryobjects/1-promise.js
A promise chain with setTimeout in javascript.
View 1-promise.js
// Demo http://jsbin.com/qevetiqavu/edit?js,output
var one = function(i) {
return new Promise((resolve, reject) => {
setTimeout(() => {
console.log(`setTimeout ${i}`);
if (i < 0) {
reject(i);
}
else if (i >= 5) {
View empty-array-of-special-length.js
/**
* es5
*/
Array.apply(null, new Array(3)) // => [undefined, undefined, undefined]
Array.apply(null, {length: 3}) // => [undefined, undefined, undefined]
/**
* es6
*/
You can’t perform that action at this time.