Aktywne Wpisy

Greensy +194
Rozwiązanie na problemy tego świata
źródło: 1000069482
Pobierz
Gieremek +164
źródło: 1000013238
PobierzSkopiuj link
Skopiuj link
źródło: 1000069482
Pobierz
źródło: 1000013238
PobierzRegulamin
Reklama
Kontakt
O nas
FAQ
Osiągnięcia
Ranking
// Definitionfunction* Enum (name = 'Unnamed enumeration') {
while (true) yield Symbol(name)
}
// Usage
const [cat,dog,catdog] = Enum('animal')
const [red,green,blue] = Enum('color')
``````
// Test
console.assert(cat === cat, 'Identity violated')
console.assert(cat !== red, 'Uniqueness violated')
console.assert(cat !== dog, 'Uniqueness violated')
console.assert(cat !== catdog, 'Uniqueness violated')
``````
// Demo
console.log(pet(cat))
console.log(pet(dog))
console.log(pet(catdog))
``````
//: Animal -> String
function pet (animal) {
return {
[cat] : 'Mauz',
[dog] : 'Wuff',
[catdog] : 'Mauff'
}[animal]
}
http://disq.us/p/18ml3re
#webdev #frontend #javascript #es6 #ecmascript #slowpoke