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
npm install --save-dev @types/jasmine |
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
declare function camelize(s: string): string; |
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
let user = { firstName: "James", lastName: "Hetfield" }; | |
console.log(greeter(user)); |
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
interface Person { | |
firstName: string; | |
lastName: string; | |
} | |
function greeter(person: Person): string { | |
return "Hello, " + person.firstName + " " + person.lastName; | |
} | |
// Jasmine spec: |
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 greeter(person) { | |
if (!person || !person.firstName || !person.lastName) { | |
throw new Error('invalid arguments'); | |
} | |
return "Hello, " + person.firstName + " " + person.lastName; | |
} | |
// Jasmine spec: | |
describe("greeter", function() { |
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 greeter(person) { | |
return "Hello, " + person.firstName + " " + person.lastName; | |
} |
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
class Greeter { | |
greeting: string; | |
constructor(message: string) { | |
this.greeting = message; | |
} | |
greet() { | |
return "Hello, " + this.greeting; | |
} |
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
class Greeter { | |
constructor(message) { | |
this.greeting = message; | |
} | |
greet() { | |
return "Hello, " + this.greeting; | |
} | |
} |
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
declare function camelize(s: string): string; |
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
- Trailing commas are ok | |
- No reserved words for property names | |
- NaN, Infinity, undefined : are all constants | |
- parseInt() defaults to radix 10 | |
- /regexp/ produces new reg ex object every time | |
- JSON.parse(), JSON.stringify() | |
- Function.prototype.bind | |
- String.prototype.trim | |
- Array.prototype.every, filter, forEach, indexOf, lastIndexOf, map, reduce, reduceRight, some, | |
- Date.now() |
NewerOlder