Skip to content

Instantly share code, notes, and snippets.

View Fabian295's full-sized avatar
🏠
Working from home

Fabian Kanhai Fabian295

🏠
Working from home
  • the Netherlands
  • 06:08 (UTC +02:00)
View GitHub Profile
let num = 0;
async function increment() {
num += await 2;
console.log(num);
}
increment();
num += 1;
console.log(num);
/****
* What is the resulting output?
//version 1
let a1 = Array.from({
length: 5
}, n => Math.random());
console.log('1', a1);
//version 2
let a2 = new Array(5).fill(1).map(n => Math.random());
console.log('2', a2);
* 0 or more matches
+ 1 or more matches
? 0 or 1 match
^ matches the start of the string or line
$ matches the end of the string or line
\ signifies an escape sequence
. matches any single character except newline
( ) capturing group. Save to reuse later
| used as a logic OR inside a capturing group
[abc] character set. Matches one of the things in the brackets
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Right-Click Menus</title>
<meta name="viewport" content="width=device-width">
<style>
*{
padding: 0;
margin: 0;
// Unicode Characters in JavaScript
// Escape Sequences in JavaScript
// http://www.unicode.org/charts/
// String.fromCharCode(num [, num, num])
// myString.charCodeAt(index)
// \u0434
// \0 \' \" \\ \n \r \t
//
//Arrays of Objects
// Efficiently combining and chaining Array methods and Arrow functions
// person.email.indexOf("@replicant.io") > -1
//Find the names of all the people who have "replicant.io" emails
let people = [
{"id":123, "name":"Rick Deckard", "email":"rick@bladerunner.org"},
{"id":456, "name":"Roy Batty", "email":"roy@replicant.io"},
{"id":789, "name":"J.F. Sebastian", "email":"j.f@tyler.com"},
{"id":258, "name":"Pris", "email":"pris@replicant.io"}
// DarkSky API
// CORS requests are NOT allowed by the DarkSky server
// Requests from other Servers are allowed
// So, we would make a pass thru file on a server.
// Browser sends the fetch( ) AJAX request to OUR server
// OUR server sends the AJAX request to DarkSky server
// DarkSky responds to OUR Server
// OUR Server sends the DarkSky reply back to Browser
// Browser AJAX call => Our Server => DarkSky => Our Server => Browser AJAX call
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Mock Server APIs in Postman</title>
<meta name="viewport" content="width=device-width">
</head>
<body>
<header>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Flexbox Getting Started</title>
<meta name="viewport" content="width=device-width">
<style>
.container{
display: flex;
flex-direction: column;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Flexbox Nav Lists</title>
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="main.css"/>
<style>
.listnav{
background-color: #bada55;