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
stages: | |
- E2E | |
.ios_base: | |
tags: | |
- macOS | |
- swiftlint | |
cache: | |
paths: | |
- node_modules |
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 Banner extends HTMLElement { | |
// Private variable that cannot be reached directly from outside, but can be modified by the methods inside: | |
#slogan = "Hello there!" | |
#counter = 0 | |
// private getters and setters (accessors): | |
get #slogan() {return #slogan.toUpperCase()} | |
set #slogan(text) {this.#slogan = text.trim()} |
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 Translator { | |
static translations = { | |
yes: 'ja', | |
no: 'nein', | |
maybe: 'vielleicht', | |
}; | |
static englishWords = []; | |
static germanWords = []; | |
static { // (A) | |
for (const [english, german] of Object.entries(this.translations)) { |
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 date = Temporal.Now.plainDateISO(); // Gets the current date | |
date.toString(); // returns the date in ISO 8601 date format | |
// If you additionally want the time: | |
Temporal.Now.plainDateTimeISO().toString(); // date and time in ISO 8601 format |
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 User { | |
isActive = false; | |
get getStatus(){ | |
if(!this.#isActive){ | |
throw new Error('User is not active'); | |
} | |
return this.#isActive; | |
} | |
} |
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
try { | |
const result = 2 / 0; | |
console.log(result); | |
} catch (error) { | |
console.err(error); | |
throw new Error('Something went wrong', { cause: error }); | |
} |
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 fruits ="Fruits:apples, oranges, pears"; | |
const regex = /(apples)/gd; | |
const matches = [...fruits.matchAll(regex)]; | |
console.log(matches[0]); |
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 person = Object.create(null); | |
person.age = 21; | |
if (Object.hasOwn(person, 'age')) { | |
console.log(person.age); // true - works regardless of how the object was created | |
} | |
if (person.hasOwnProperty('age')){ // throws error - person.hasOwnProperty is not a function | |
console.log('hasOwnProperty: ', person.age); | |
} |
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 fruits = ['apples', 'oranges', 'pears']; | |
console.log(fruits[fruits.length - 1]); // pears | |
console.log(fruits.at(0)); // apples | |
console.log(fruits.at(-1)); // pears |
NewerOlder