Skip to content

Instantly share code, notes, and snippets.

View ObsidianCat's full-sized avatar

Lula Leus ObsidianCat

View GitHub Profile
// Object destructuring
//Object
const response = {
status: 200,
data: {
user: {
name: 'Rachel',
title: 'Editor in Chief'
},
function delayedRandom(){
const random = Math.random();
return new Promise(resolve => setTimeout(()=>resolve(random), 100));
}
async function* generateDelayedRandoms(){
let num;
num = await delayedRandom()
yield 'One ' + num;
const { getRandomWordSync, getRandomWord } = require("word-maker");
const fs = require("fs");
console.log("It works!");
// YOUR CODE HERE
//Additional functions
//asynchronous in loop
@ObsidianCat
ObsidianCat / type-script-basics.ts
Last active December 6, 2019 17:21
Examples of type script basics types and their use
//inferance bottom up
// the compiler know function result type, baesed on it`s arguments
let userId = (a: string, b: number): string =>a+b;
//*******************************
//Union type (variable can be any of these types)
let thing: string | number | string[];
// Alias
type thing = string | number | string[];