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
/* | |
Bitwise permissions in JavaScript. | |
Take a look at the original Instagram post for an explanation as to how this works! | |
https://www.instagram.com/p/CB1QSWIAq9d | |
*/ | |
// Permissions | |
const read = 1; | |
const write = 2; | |
const remove = 4; |
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
/* | |
Working with the Cryptonator API in NodeJS. | |
Take a look at the original Instagram post! | |
https://www.instagram.com/p/CB_BQ87ldEA/ | |
*/ | |
const axios = require("axios"); | |
// Cryptonator API (use "https://api.crytonator.com/api/full" for additional data) | |
const URL = "https://api.crytonator.com/api/ticker"; |
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
/* | |
Convert an object into an ES6 map with this simple yet effective trick. | |
Take a look at the original Instagram post! | |
https://www.instagram.com/p/CCJw3YJAvO0/ | |
*/ | |
const data = { | |
name: "John Doe", | |
age: 20, | |
address: "Main Street 123" |
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
/* | |
Detect changes in internet connection using nothing but pure JavaScript. | |
Take a look at the original Instagram post! | |
https://www.instagram.com/p/CCWs55wgWjM/ | |
*/ | |
let isOnline = navigator.onLine; | |
if(isOnline) { | |
// Do something... |
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
/* | |
Get the current time using the JavaScript Date object and | |
converting it into an ISO string. | |
Take a look at the original Instagram post! | |
https://www.instagram.com/p/CCZZV7MgECh/ | |
*/ | |
// Retrieve current data | |
const now = new Date(); |
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
/* | |
Merge two or more maps using the ES6 spread syntax. | |
Take a look at the original Instagram post! | |
https://www.instagram.com/p/CCjj7ySgV_N/ | |
*/ | |
let map1 = new Map([ | |
["name", "John Doe"], | |
["age", 20] | |
]); |
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
/* | |
Basic array sorting with Array.sort(). | |
Take a look at the original Instagram post! | |
https://www.instagram.com/p/CCt5fSJgom7/ | |
*/ | |
let array = [ "Hello", 3, 1, 7, "World" ]; | |
array.sort(); |
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
/* | |
Retrieve an IP geolocation using JavaScript. | |
This API has great docs, make sure to check them out if you're interested | |
in using it: https://ip-api.com/docs | |
Take a look at the original Instagram post! | |
https://www.instagram.com/p/CDGrgoLgWbi/ | |
*/ | |
// You can use any other HTTP library, of course! | |
const axios = require("axios"); |
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
/* | |
What's "this" in JavaScript (inside of a constructor)? | |
Take a look at the original Instagram post! | |
https://www.instagram.com/p/CDrcMOgAQgO/ | |
*/ | |
function Person(name) { | |
this.name = name; | |
} |
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
/* | |
What's the "super" keyword in JavaScript? | |
This gist and the Instagram post assume that you already have a | |
basic understanding of object-oriented programming. | |
Take a look at the original Instagram post! | |
https://www.instagram.com/p/CDtbJvVgpuU/ | |
*/ | |
// Parent class | |
class Shape { |
OlderNewer