Skip to content

Instantly share code, notes, and snippets.

@blaja
blaja / .html
Last active August 29, 2015 14:26
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<style>
body {height: 100vh;display: flex;align-items: center;justify-content: center;}
/* Button component - works only in FF correctly ATM */
@blaja
blaja / .js
Last active August 29, 2015 14:26
Not worth a look!
// Navigate to different location using different BOM && DOM API-s. Paralysis of choice :) Are there more ways ?
location = 'https://www.google.com/';
location.href = 'https://www.google.com/';
window.location = 'https://www.google.com/';
document.location = 'https://www.google.com/';
window.location.href = 'https://www.google.com/';
@blaja
blaja / .js
Created August 1, 2015 14:34
Fetch some JSON using Fetch API
const request = new Request('https://output.jsbin.com/pasixu.js', {
method: 'GET',
requestMode: 'cors',
});
fetch(request).then(function(response) {
return response.json();
}).then(function(body) {
console.log(body);
}).catch(function(){
@blaja
blaja / .js
Last active August 29, 2015 14:26
Simple way to exclude webkit prefixed props in Chrome using some ES6 features.
// Filter out CSS properties without webkit prefixes in Chrome console
// To find "hidden" properties of an object we need to use Object.getOwnPropertyNames.
Object.getOwnPropertyNames(document.body.style).filter(
property => !property.startsWith('webkit')
);
(function () {
'use strict';
return this === undefined; // false
}.call(this));
(function(global){
'use strict';
document.getElementById('btn').addEventListener('click', function() {
"use strict";
const evens = Array.from(document.getElementsByClassName('even'));
for(let even of evens) {
even.classList.toggle('bold');
even.nextElementSibling.classList.toggle('italic');
}
});