Hi, @christian-bromann
This file contains hidden or 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 { Component, ElementRef, Inject, Input, OnInit } from '@angular/core'; | |
| import { DOCUMENT } from '@angular/common'; | |
| type ILocalOccurrences = Array<[number, number]>; | |
| @Component({ | |
| selector: 'ui-highlight', | |
| template: '', | |
| }) | |
| export class HighlightComponent implements OnInit { |
This file contains hidden or 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 namespace Feast { | |
| interface Block { | |
| extend: (props: any) => Block; | |
| get: (prop: string) => any; | |
| set: (prop: string, value: any) => void; | |
| } | |
| interface Feast { | |
| Block: Block | |
| } |
This file contains hidden or 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 logClass(target: any) { | |
| // save a reference to the original constructor | |
| var original = target; | |
| // a utility function to generate instances of a class | |
| function construct(constructor, args) { | |
| var c : any = function () { | |
| return constructor.apply(this, args); | |
| } |
This file contains hidden or 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
| try { | |
| ... | |
| } catch (TypeError) { | |
| console.log('Не массив'); | |
| } |
This file contains hidden or 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 assert = require('assert'); | |
| const d = { | |
| I: 1, V: 5, X: 10, L: 50, C: 100, D: 500, M: 1000, IV: 4, IX: 9, XL: 40, XC: 90, CD: 400, CM: 900 | |
| }; | |
| const f = i => eval(i.replace(/(I(V|X)?|X(L|C)?|C(D|M)?|V|L|D|M)/ig, l => '+' + d[l])); | |
| assert.equal(f('I'), 1, 'I=' + f('I')); | |
| assert.equal(f('XI'), 11, 'XI=' + f('XI')); |
This file contains hidden or 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 assert = require('assert'); | |
| const numbersDict = { | |
| I: 1, V: 5, X: 10, L: 50, C: 100, D: 500, M: 1000 | |
| }; | |
| const fromRoman = input => [...input.toUpperCase()].reduce((number, letter, i, source) => number + (numbersDict[letter] >= ( numbersDict[source[i + 1]] | 0)) ? numbersDict[letter] : -numbersDict[letter], 0); | |
| assert.equal(fromRoman('I'), 1, 'I=' + fromRoman('I')); | |
| assert.equal(fromRoman('XI'), 11, 'XI=' + fromRoman('XI')); |
This file contains hidden or 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
| // https://github.com/jshttp/mime-types | |
| const sexyMap = { | |
| 'js' : 'application/javascript', | |
| 'css' : 'text/css' | |
| } | |
| const contentType = url => sexyMap[url.split('.').pop()] || 'text/plain'; | |
| console.log([ |
Пропустить теорию и перейти прямо к задачам
Ссылка на учебник: http://learn.javascript.ru
Сразу расскажу про несколько особенностей яваскрипта, о которых может быть не написано (или мало написано) в учебниках, но которые стоит понимать: