C

@ch_sushma12

map-deep-dive

TypeScript
4 years ago
const familyNames = ["Jordan", "Tiffany", "Kristine"]; // let capitalizedNames: string[] = []; // for (var i = 0; i < familyNames.length; i++) { // capitalizedNames.push(familyNames[i].toUpperCase()) // } // console.log(capitalizedNames)

capitalize first letter

TypeScript
4 years ago
const pageTitle1 = "some amazing title"; const pageTitle2 = "Another Amazing Title"; const pageTitle3 = "A rEAlY weIrd TiTLE"; const pageTitle4 = ""; const capitalizeWord = (str: string) => { const firstChar = str.charAt(0).toLocaleUpperCase(); const restOfStr = str.substring(1).toLocaleLowerCase(); return `${firstChar}${restOfStr}`;

optional chaining

TypeScript
4 years ago
type EmployeeType = { email: string; roles?: string[]; } let data: {employees?: EmployeeType[]}; data = { employees: [ {email: "test@example.com", roles: ["admin", "superAdmin"]},

class decorators

TypeScript
4 years ago
@detailedLog('billing') class AccountsPayable { constructor() {} @admin deleteAccount() { console.log('Deleting account...'); } }

Array Functions

TypeScript
4 years ago
var fullName = (first, last) => { return first + " " + last; } console.log(fullName('Jordan', 'Hudgens')); // Jordan Hudgens var gradeGenerator = (grade: number) : string => { if (grade < 60) {

conditional operators

TypeScript
4 years ago
let x : number = 100; // if(x == 200) { // console.log('Condition passed'); // } if(x === 100) { console.log('Condition passed'); }

method decorators

TypeScript
4 years ago
@detailedLog('billing') class AccountsPayable { constructor() {} @admin deleteAccount() { console.log('Deleting account...'); } }

class decorators

TypeScript
4 years ago
@detailedLog('billing') class AccountsPayable { constructor() {} @admin deleteAccount() { console.log('Deleting account...'); } }

decorators

TypeScript
4 years ago
class Post { @processOne() @processTwo() someFunction() {} } function processOne() { console.log("processOne has run"); return function (target, propertyKey : string, descriptor : PropertyDescriptor) { console.log("processOne has been called");

promises

TypeScript
4 years ago
"use strict"; // Start mowing -> Pending // Complete mowing process -> Resolve // Did not complete mowing process -> Reject let performUpload = function(imgStatus : string) : Promise<{imgStatus : string}> { return new Promise((resolve) => { console.log(`Status: ${imgStatus}`); setTimeout(() => {

promises

TypeScript
4 years ago
"use strict"; // Start mowing -> Pending // Complete mowing process -> Resolve // Did not complete mowing process -> Reject let performUpload = function(imgStatus : string) : Promise<{imgStatus : string}> { return new Promise((resolve) => { console.log(`Status: ${imgStatus}`); setTimeout(() => {

higher order functions and callbacks

TypeScript
4 years ago
var dbQuery = function() : void { setTimeout(() => { console.log('Query results'); }, 3000); } function loadPage(q : () => void) { console.log("Header"); q(); console.log("Sidebar");

this

TypeScript
4 years ago
class Invoice { total : number; constructor(total : number) { this.total = total; } printTotal() { console.log(this.total); }

Namespaces

TypeScript
4 years ago
namespace Blog { export interface IPost { title: string; body: string; } export class Post implements IPost { title: string; body: string;

classes implementing Interfaces

TypeScript
4 years ago
// Loosely connected Interface with Class interface User { email: string; firstName? : string; lastName? : string; } class Admin { role : string; constructor(public email : string) {

function to work with Interfaces

TypeScript
4 years ago
interface InvoiceFunc { (name : string, total : number) : void; } let myInvoice : InvoiceFunc; myInvoice = function(n, t) { console.log(n); console.log(t); }

Interfaces

TypeScript
4 years ago
interface User { email : string; firstName? : string; lastName? : string; } function profile(user: User) : string { return `Welcome, ${user.email}`; }

Objects

TypeScript
4 years ago
var realUser = { email: 'test@test.com', firstName: 'Jordan', lastName: 'Hudgens', sayHi() { return "Hey there!"; } }; console.log(realUser.email);

inheritance

TypeScript
4 years ago
class Report { companyProfile : string; constructor(public name : string) { this.companyProfile = name; } } class Invoice extends Report { constructor(public name : string, public total : number) { super(name); }

classes

TypeScript
4 years ago
class Invoice { companyProfile : string; constructor(public name, public city, public state) { this.companyProfile = name + ", " + city + ", " + state; } } var googleInvoice = new Invoice('Google', 'Mountain View', 'State'); var yahooInvoice = new Invoice('Yahoo', 'SF', 'State');