Skip to content

Instantly share code, notes, and snippets.

View muodov's full-sized avatar
🐢
turtles!

Maxim Tsoy muodov

🐢
turtles!
View GitHub Profile
@muodov
muodov / cheatsheet.js
Last active April 24, 2024 10:05
JS prototype inheritance cheatsheet
// normal function x
function x() {
this.a = 1;
}
// First of all, the term "prototype" is confusing because it can refer to 2 different things.
// There is an object's prototype, which is another object used to look up missing properties.
// But there is also an actual `prototype` property on Function and class objects, which is NOT a prototype for that function object!
// Instead, it serves a very specific purpose: that object becomes a prototype of all instances returned when that function is used as a constructor:
(new x()).__proto__ === x.prototype
@muodov
muodov / empty-hash-assignment.md
Last active February 24, 2022 17:42
Location and links behaviour when setting empty hash
Command (executed in this order) Chrome 72 Firefox 65 Safari 12.0.3 IE11
window.location.hash "" "" "" ""
window.location.href "https://example.com/" "http://example.com/" "http://example.com/" "http://example.com/"
window.location.hash = '#' "#" "#" "#" "#"
window.location.href "https://example.com/" "http://example.com/#" "http://example.com/" "http://example.com/#"
window.location.hash "" "" "" "#"
window.location.hash = '#1' "#1" "#1" "#1" "#1"
window.location.href "https://example.com/#1" "http://example.com/#1" "http://example.com/#1"
@muodov
muodov / session-id.html
Created October 11, 2017 15:10
surfly session id approach
<html>
<head></head>
<body>
<div id="surfly-control" class="hidden">CLICK ME!</div>
<style>
.start-surfly {
cursor: pointer;
color: red;
}