{"id":20003628,"url":"https://github.com/xenioushk/frequently_used_js_codes","last_synced_at":"2025-10-21T18:08:32.296Z","repository":{"id":146626797,"uuid":"516663454","full_name":"xenioushk/frequently_used_js_codes","owner":"xenioushk","description":null,"archived":false,"fork":false,"pushed_at":"2024-09-15T08:07:22.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-12T13:26:49.813Z","etag":null,"topics":["javascript","javascript-examples-beginners","javascript-snippets"],"latest_commit_sha":null,"homepage":"https://bluewindlab.net","language":null,"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/xenioushk.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":"2022-07-22T08:02:51.000Z","updated_at":"2024-09-15T08:08:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"cec1330d-1e0c-4d9b-8c43-fcb8cfc04d2c","html_url":"https://github.com/xenioushk/frequently_used_js_codes","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xenioushk%2Ffrequently_used_js_codes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xenioushk%2Ffrequently_used_js_codes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xenioushk%2Ffrequently_used_js_codes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xenioushk%2Ffrequently_used_js_codes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xenioushk","download_url":"https://codeload.github.com/xenioushk/frequently_used_js_codes/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241442900,"owners_count":19963695,"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":["javascript","javascript-examples-beginners","javascript-snippets"],"created_at":"2024-11-13T05:26:30.128Z","updated_at":"2025-10-21T18:08:27.265Z","avatar_url":"https://github.com/xenioushk.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Frequently Used JS Codes\n\n## Get all the child elements\n\n```javascript\nvar all_checkbox = document.getElementById(\"gg_data_tags\").querySelectorAll('input[type=\"checkbox\"]')\n```\n\n## Loop for the child elements\n\n```javascript\nall_checkbox.forEach(function (item) {\n  item.checked = false\n})\n```\n\n## Add Class to an element\n\n```javascript\nthis.result_player_two.classList.add(\"current-player\")\n```\n\n## Add Multiple Classes to an element\n\n````javascript\nthis.result_player_two.classList.add(\"current-player\", \"class_2\", \"class_3\")```\n\n## Remove Class from an element\n\n```javascript\nthis.result_player_one.classList.remove(\"current-player\")\n````\n\n## Add 'id' attribute to an element\n\n```javascript\nthis.result_player_one.setAttribute(\"id\", \"my-id\")\n```\n\n## Add custom attribute to an element\n\n```javascript\nthis.result_player_one.setAttribute(\"data-score\", \"10\")\n```\n\n## Remove 'class' attribute from an element\n\n```javascript\nthis.result_player_one.removeAttribute(\"class\")\n```\n\n## Remove Multiple Classes to an element\n\n```javascript\nthis.result_player_two.classList.remove(\"class_2\", \"class_3\")\n```\n\n## Force checkbox to check\n\n````javascript\ndocument.getElementById(\"checkbox\").checked = true;```\n\n## Force checkbox to uncheck\n\n```javascript\ndocument.getElementById(\"checkbox\").checked = false;\n````\n\n## Push data to array \u003c/b\u003e\n\n```javascript\nvar sel_authors = new Array()\nsel_authors.push(\"john\", \"mahbub\", \"alam\", \"khan\")\n```\n\n## Random value betwen two numbers\u003c/b\u003e\n\n```javascript\n randomIntFromInterval(min, max) { // min and max included\n    return Math.floor(Math.random() * (max - min + 1) + min)\n  }\n```\n\n## Join Array\n\n```javascript\nconst fruits = [\"Banana\", \"Orange\", \"Apple\", \"Mango\"]\nlet text = fruits.join()\n```\n\n## Array Map\n\n```javascript\nconst numbers = [65, 44, 12, 4]\nconst newArr = numbers.map(myFunction)\n\nfunction myFunction(num) {\n  return num * 10\n}\n```\n\n### More example\n\nYou can check more javascript example codes from [here](https://github.com/xenioushk/javascript_101).\n\n## Acknowledgement\n\n- [bluewindlab.net](https://bluewindlab.net)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxenioushk%2Ffrequently_used_js_codes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxenioushk%2Ffrequently_used_js_codes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxenioushk%2Ffrequently_used_js_codes/lists"}