This file contains 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
export const arrayofRandom = randomCeil => length => Array.from({ length: length }, (v, i) => Math.floor(Math.random() * randomCeil)); |
This file contains 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
var Tristate; | |
(function (Tristate) { | |
Tristate[Tristate["False"] = 0] = "False"; | |
Tristate[Tristate["True"] = 1] = "True"; | |
Tristate[Tristate["Unknown"] = 2] = "Unknown"; | |
})(Tristate || (Tristate = {})); |
This file contains 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
enum Weekday { | |
Monday, | |
Tuesday, | |
Wednesday, | |
Thursday, | |
Friday, | |
Saturday, | |
Sunday | |
} | |
namespace Weekday { |
This file contains 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
/// <reference path="Validation.ts" /> | |
namespace Validation { | |
const lettersRegexp = /^[A-Za-z]+$/; | |
export class LettersOnlyValidator implements StringValidator { | |
isAcceptable(s: string) { | |
return lettersRegexp.test(s); | |
} | |
} | |
} |
This file contains 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
function counter(state = 0, action) { | |
switch (action.type) { | |
case 'INCREMENT': | |
return state + 1 | |
case 'DECREMENT': | |
return state - 1 | |
default: | |
return state | |
} | |
} |
This file contains 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
import { NgModule } from '@angular/core'; | |
import { RouterModule, Routes } from '@angular/router'; | |
import { DashboardComponent } from './dashboard/dashboard.component'; | |
import { HeroesComponent } from './heroes/heroes.component'; | |
import { HeroDetailComponent } from './hero-detail/hero-detail.component'; | |
const routes: Routes = [ | |
{ path: '', redirectTo: '/dashboard', pathMatch: 'full' }, | |
{ path: 'dashboard', component: DashboardComponent }, |
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Prototype Performance</title> | |
<meta charset="UTF-8" /> | |
</head> | |
<body> | |
<div id="app" style="margin:100px"></div> |
This file contains 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
const sum = new Function('a', 'b', 'return a + b'); | |
console.log(sum(2, 6)); | |
// expected output: 8 |
This file contains 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
function calcRectArea(width, height) { | |
return width * height; | |
} | |
console.log(calcRectArea(5, 6)); |
This file contains 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
var hoisted = "foo" in this; | |
console.log(`'foo' name ${hoisted ? "is" : "is not"} hoisted. typeof foo is ${typeof foo}`); | |
if (false) { | |
function foo(){ return 1; } | |
} | |
// In Chrome: | |
// 'foo' name is hoisted. typeof foo is undefined | |
// | |
// In Firefox: |
OlderNewer