This file contains hidden or 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
{ | |
"printWidth": 120, | |
"tabWidth": 2, | |
"useTabs": false, | |
"semi": false, | |
"singleQuote": true, | |
"trailingComma": "es5", | |
"bracketSpacing": true, | |
"jsxBracketSameLine": false | |
} |
This file contains hidden or 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
const getUser = emailIncluded => ({ | |
name: 'dead', | |
surname: 'kff01', | |
...(emailIncluded ? { email : '[email protected]' } : null) | |
}) | |
console.log(getUser(true)) | |
// destructuring | |
const rawUser = { |
This file contains hidden or 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
class Deferred { | |
constructor(){ | |
this.canceled = false | |
this.promise = new Promise((resolve, reject) => { | |
this.resolve = (value) => { | |
if(!this.canceled) resolve(value) | |
} | |
this.reject = (value) => { | |
if(!this.canceled) reject(value) | |
} |
This file contains hidden or 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
#my-div * { | |
animation : none; | |
animation-delay : 0; | |
animation-direction : normal; | |
animation-duration : 0; | |
animation-fill-mode : none; | |
animation-iteration-count : 1; | |
animation-name : none; | |
animation-play-state : running; | |
animation-timing-function : ease; |
This file contains hidden or 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
// recursive method | |
const getElementsByClassNameRec = (className) => { | |
let nodeList = [] | |
function find(node) { | |
if (node.classList && node.classList.contains(className)) | |
nodeList.push(node) | |
for (let i = 0; i < node.childNodes.length; i++) | |
find(node.childNodes[i]) | |
return nodeList | |
} |
This file contains hidden or 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
class HashTable{ | |
constructor(size=42){ | |
this.buckets = new Array(size) | |
this.size = size | |
} | |
hash(key){ | |
return key.toString().length % this.size; | |
} |
This file contains hidden or 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
let https = require('https') | |
const httpGetAsync = (url, callback) => { | |
return https.get(url, | |
(response) => { | |
var body = '' | |
response.on('data', (d) => { | |
body += d | |
}) | |
response.on('end', () => { |
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script> | |
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> |
This file contains hidden or 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
import React, { Component } from 'react'; | |
import { render } from 'react-dom'; | |
import { createStore, combineReducers } from 'redux'; | |
import { connect, Provider } from 'react-redux'; | |
const countReducer = (state = { count: 0 }, action) => { | |
switch (action.type) { | |
case 'INC': return { count: state.count + 1 }; | |
case 'DEC': return { count: state.count - 1 }; | |
default: return state; |
This file contains hidden or 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
<button type="button" id="btn">Show my IP</button> | |
<div id="ipContainer"></div> | |
<script> | |
const btn = document.getElementById('btn') | |
const ipContainer = document.getElementById('ipContainer') | |
const fetchJSON = async (req) => { | |
const request = await fetch(req) | |
return request.json(); | |
} |