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 size of an object in JavaScript! | |
Method 1: Manually counting each property | |
Take a look at the original Instagram post! | |
https://www.instagram.com/p/CG3GNHiAFbq/ | |
*/ | |
const getSize = (object) => { | |
let size = 0; | |
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
/* | |
Retrieving the current time in JavaScript—here are three ways to do it! | |
Method 2: Date object | |
Take a look at the original Instagram post! | |
https://www.instagram.com/p/CGyGduqgiVV/ | |
*/ | |
let now = new Date(); | |
// Create timestamp |
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
/* | |
Encrypt and decrypt messages easily with CryptoJS! | |
Take a look at the original Instagram post! | |
https://www.instagram.com/p/CGsyg27gO0E/ | |
*/ | |
const { AES, enc } = require("crypto-js"); | |
// Your password (it should be kept in a seperate file, but | |
// for the sake of simplicity it's hardcoded!) |
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
/* | |
A really simple weather app in NodeJS. | |
(Hardcoded location. See other file for version with process args.) | |
Take a look at the original Instagram post! | |
https://www.instagram.com/p/CGqGcCUggYK/ | |
*/ | |
const weather = require("weather"); | |
// Options for the search |
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
/* | |
JavaScript labels: usage with nested for-loops! | |
Take a look at the original Instagram post! | |
https://www.instagram.com/p/CGkxCv6ge1U/ | |
*/ | |
outerLoop: | |
for(let i = 0; i < 3; i++) { | |
innerLoop: | |
for(let j = 0; j < 3; j++) { |
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
/* | |
Static keyword in JavaScript: what, why and when. | |
Take a look at the original Instagram post! | |
https://www.instagram.com/p/CFnMKRbArjI/ | |
*/ | |
class Person { | |
// A static method | |
static hello() { | |
console.log("Hello"); |
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
{ | |
"name": "John", | |
"age": 20, | |
"languages": [ | |
"JavaScript", | |
"PHP" | |
] | |
} |
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
/* | |
Data structures: Queues in JavaScript. | |
Take a look at the original Instagram post! | |
https://www.instagram.com/p/CEnAZEDgiby/ | |
*/ | |
class Queue { | |
constructor() { | |
// List of elements | |
this.elements = []; |
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
/* | |
RxJS Observables: How do they work? | |
Take a look at the original Instagram post! | |
https://www.instagram.com/p/CD7MXBSAlwm/ | |
*/ | |
const { Observable } = require("rxjs"); | |
// Function to generate numbers between 1 and 10 | |
const random = () => Math.floor(Math.random() * (10 - 1) + 1); |
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 { |
NewerOlder