29
const getSum = arr => { let sum = 0 for(let i = 0 ; i < arr.length; i++) { sum += arr[i] } return sum }const sum = arr.reduce((a,b)=>a+b)export type JsonObject = {[Key in string]?: JsonValue}; export interface JsonArray extends Array<JsonValue> {} export type JsonValue = string | number | boolean | null | JsonObject | JsonArray;export type Split<S extends string, D extends string> = string extends S ? string[] : S extends '' ? [] : S extends `${infer T}${D}${infer U}` ? [T, ...Split<U, D>] : [S];class Counter extends HTMLElement { #xValue = 0; get #x() { return #xValue; } set #x(value) { this.#xValue = value; window.requestAnimationFrame(this.#render.bind(this)); } #clicked() { this.#x++; } constructor() { super(); this.onclick = this.#clicked.bind(this); } connectedCallback() { this.#render(); } #render() { this.textContent = this.#x.toString(); } } window.customElements.define('num-counter', Counter);
Last updated


