{"id":21437987,"url":"https://github.com/olhkyle/fxjs-verstenden","last_synced_at":"2025-03-16T23:42:45.219Z","repository":{"id":176941828,"uuid":"657170130","full_name":"olhkyle/fxjs-verstenden","owner":"olhkyle","description":"Learn fxjs based on functional-programming concept","archived":false,"fork":false,"pushed_at":"2023-06-28T15:22:26.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-23T09:44:30.400Z","etag":null,"topics":["functional-programming","fxjs","javascript"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/olhkyle.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-22T13:20:38.000Z","updated_at":"2024-08-14T09:48:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"1d8f4293-f7eb-4130-b6a6-eacf6ca38e42","html_url":"https://github.com/olhkyle/fxjs-verstenden","commit_stats":null,"previous_names":["olhkyle/fxjs-practice","olhkyle/fxjs-verstenden"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olhkyle%2Ffxjs-verstenden","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olhkyle%2Ffxjs-verstenden/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olhkyle%2Ffxjs-verstenden/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olhkyle%2Ffxjs-verstenden/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/olhkyle","download_url":"https://codeload.github.com/olhkyle/fxjs-verstenden/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243950806,"owners_count":20373664,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["functional-programming","fxjs","javascript"],"created_at":"2024-11-23T00:31:27.971Z","updated_at":"2025-03-16T23:42:45.186Z","avatar_url":"https://github.com/olhkyle.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FxJS\n\nTry to learn `functional programming` (Iterable Program - LISP)\n\n\u003e 📎 based on \u003ca href=\"https://github.com/marpple/FxJS/blob/master/README_kr.md#Getting-Started\"\u003eFxjs Library\u003c/a\u003e\n\n\u003cbr/\u003e\n\u003cbr/\u003e\n\n\u003ccode\u003e💡 The following article is a compilation of some of the basic concepts I've learned about iterables.\u003c/code\u003e\n\n\u003e Important Concept of Functional Programming in ES6+\n## Iteration Protocol - introduced in ES6\nIt's the pre-promised rule written on ECMASCRIPT SPECS which is order to make iterable data collection\n\nPrior to ES6, without the unified rule, iterable data collection such as Array, String, array-like-Object \n and DOM Collections(NodeList, HTMLCollection)  could be traversed or looped in multiple ways using `for...in`, `for` statement and `forEach` method.\n\nES6 unifies iterable data collection into iterables that conform to the `iteration protocol` so that they can be used as targets of `for ... of` statements, `spread syntax`, and `array destructuring assignments`.\n\n\u003cbr/\u003e\n\u003cbr/\u003e\n\n### `1. iterable protocol`\nCalling a method that uses the well-known Symbol `Symbol.iterator` as a property key, and implementing it yourself or inheriting it from `prototype chain` will return an `iterator` that conforms to the `iterator protocol`. This convention is called the `iterable protocol`, and an object that conforms to the `iterable protocol` is called an `iterable`.\n\n`Iterable` can be traversed by `for...of` statements, used in spread syntax, and assigned as targets for array destructuring.\nThat's why we use String as iterable.\n\n```js\nconst str = 'string';\nconsole.log([...str]); // ['s', 't', 'r', 'i', 'n', 'g'];\n```\n\n\u003cbr/\u003e\n\u003cbr/\u003e\n\n### `2. iterator protocol`\n\nCalling `Symbol.iterator` on an `iterable` returns an `iterator` that conforms to the `iterator protocol`. The `iterator` owns a `next` method, which when called traverses the iterable and returns an iterator `result` object with properties `value` and `done`.\n\nAn object that conforms to the `iterator protocol` is called an `iterator`, and an iterator do as a pointer to navigate through the elements of an `iterable`.\n\n```js\nconst arr = [1,2,3];\nconst iterator = arr[Symbol.iterator]();\n// Array Iterator {}\n// [[Prototype]]: Array Iterator\n\nconsole.log(iterator.next()); // { value: 1. done: false }\nconsole.log(iterator.next()); // { value: 2. done: false }\nconsole.log(iterator.next()); // { value: 3. done: false }\nconsole.log(iterator.next()); // { value: undefined. done: true }\n```\n\nWe can say `Array`, `String`, `Map`, `Set`, NodeList, HTMLCollection(DOM Collection) are an `iterable`.\n\ne.g.\n`Array` is an `iterable` which extends `Symbol.iterator `method from `Array.prototype`. That's why it can be looped and traverse by `for...of` and can be used as the target of `Spread Syntax` and `Array Destructuring Assignments`.\n\n```js\nconst array = [1, 3, 5];\n\nconsole.log(Symbol.iterator in array); // true\n\nfor (const item of array) {\n  console.log(item); \n  // 1\n  // 3\n  // 5\n}\n\nconst [a, ...rest] = array;\nconsole.log(a); // 1\nconsole.log(rest); // [3,5]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folhkyle%2Ffxjs-verstenden","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Folhkyle%2Ffxjs-verstenden","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folhkyle%2Ffxjs-verstenden/lists"}