{"id":21162413,"url":"https://github.com/lgope/javascript","last_synced_at":"2025-07-27T18:04:56.292Z","repository":{"id":119814469,"uuid":"229449376","full_name":"lgope/JavaScript","owner":"lgope","description":"The goal of this repo is to save my js programs. Basics of JavaScript.🗽 🚀","archived":false,"fork":false,"pushed_at":"2024-06-22T05:03:12.000Z","size":2093,"stargazers_count":11,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-05T02:02:51.041Z","etag":null,"topics":["array-manipulations","array-methods","async-await","asynchronous-programming","dom-manipulation","expressjs","html5","http-requests","javascript","javascript-async-await","javascript-dom","javascript-es6","javascript-es7-snippets","javascript-oop","jquery","node-js","objects","patterns","regex"],"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/lgope.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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":"2019-12-21T15:50:50.000Z","updated_at":"2024-06-22T05:03:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"fe1299c0-5741-4ad4-b24f-8af239f13f39","html_url":"https://github.com/lgope/JavaScript","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lgope/JavaScript","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lgope%2FJavaScript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lgope%2FJavaScript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lgope%2FJavaScript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lgope%2FJavaScript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lgope","download_url":"https://codeload.github.com/lgope/JavaScript/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lgope%2FJavaScript/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264476253,"owners_count":23614478,"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":["array-manipulations","array-methods","async-await","asynchronous-programming","dom-manipulation","expressjs","html5","http-requests","javascript","javascript-async-await","javascript-dom","javascript-es6","javascript-es7-snippets","javascript-oop","jquery","node-js","objects","patterns","regex"],"created_at":"2024-11-20T13:28:51.333Z","updated_at":"2025-07-09T14:32:37.464Z","avatar_url":"https://github.com/lgope.png","language":"JavaScript","readme":"# JavaScript\n*JavaScript, often abbreviated as JS, is a programming language that conforms to the ECMAScript specification. JavaScript is high-level, often just-in-time compiled, and multi-paradigm. It has curly-bracket syntax, dynamic typing, prototype-based object-orientation, and first-class functions. The of this repo is to save my js programs. Basics of JavaScript. Beginner level.*\n\n## Table of Contents\n\n  1. [Important Methods](#methods)\n  \n## Methods\n\u003e  Hello Javascript\n\n\u003ca name=\"typeof\"\u003e\u003c/a\u003e\u003ca name=\"1.1\"\u003e\u003c/a\u003e\n- [1.1](#typeof) **typeof**: Returns the type.\n \n ```javascript\n console.log(typeof 44); // number\n\n console.log(typeof 'something'); // string \n \n console.log(typeof true); // boolean\n \n let num = 12;\n console.log(typeof(num)); // number\n \n ```\n\n\u003ca name=\"toString\"\u003e\u003c/a\u003e\u003ca name=\"1.2\"\u003e\u003c/a\u003e\n- [1.2](#toString) **toString**: Returns the string representation of the number's value.\n \n ```javascript\n let num = 10;\n let n = num.toString();\n \n console.log(typeof(num)); // number\n \n console.log(typeof(n)); // string\n ```\n\n\u003ca name=\"indexOf\"\u003e\u003c/a\u003e\u003ca name=\"1.3\"\u003e\u003c/a\u003e\n- [1.3](#indexOf) **indexOf**: Returns the first index at which a given element can be found in the array, or -1 if it is not present.\n \n ```javascript\n let str = \"Hello world, welcome to the JS Universe.\";\n console.log(str.indexOf(\"welcome\")); // 13\n console.log(str.indexOf(\"wall\")); // -1\n \n const fruits = ['Orange', 'Pineapple', 'Apple', 'Melon'];\n console.log(fruits.indexOf('Melon')); // 3\n \n console.log(fruits.indexOf('klkljkh')); // -1\n ```\n \n\u003ca name=\"lastIndexOf\"\u003e\u003c/a\u003e\u003ca name=\"1.4\"\u003e\u003c/a\u003e\n- [1.4](#lastIndexOf) **lastIndexOf**: Returns the last index at which a given element can be found in the array, or -1 if it is not present.\n \n ```javascript \n const fruits = ['Orange', 'Pineapple', 'Apple', 'Melon'];\n console.log(fruits.lastIndexOf('Melon')); // 3\n \n console.log(fruits.lastIndexOf('klkljkh')); // -1\n ```\n \n \u003ca name=\"length\"\u003e\u003c/a\u003e\u003ca name=\"1.5\"\u003e\u003c/a\u003e\n- [1.5](#length) **length**: Returns the number of characters or size in a string or array.\n \n ```javascript \n const fruits = ['Orange', 'Pineapple', 'Apple', 'Melon'];\n console.log(fruits.length); // 4\n \n let str = \"Hello world, welcome to the JS Universe.\";\n console.log(str.length); // 40\n ```\n\n  \u003ca name=\"interview\"\u003e\u003c/a\u003e\u003ca name=\"1.6\"\u003e\u003c/a\u003e\n- [1.6](#length) **Interview Qus**: Tricky JavaScript Interview Questions and Answers\n \n ```javascript \n// remove duplicates form and array\nlet arr = [1, 2, 2, 3, 4];\n\nconsole.log([...new Set(arr)]);\n\n// output test 1\nconsole.log(5 \u003c 6 \u003c 7); // true // 5 \u003c 6 =\u003e true =\u003e true \u003c 7 =\u003e true = 1 =\u003e 1 \u003c 7 =\u003e true\n\nconsole.log(7 \u003e 6 \u003e 5); // false // 7 \u003e 6 =\u003e true =\u003e true \u003e 5 =\u003e true = 1 =\u003e 1 \u003e 5 = false\n\nconsole.log(Math.max()); // -Infinity lowest min number in js\nconsole.log(Math.max(1, 2, 3, 4)); // 4\n\n\n// obj\nlet profile = {\n    name: 'Lakshman'\n};\n\n// Object.freeze(profile); // freeze don't allow insert and update\nObject.seal(profile); // freeze don't allow insert, remove but allow update\n\nprofile.name = 'Gope';\n\nconsole.log(profile);\n\n// obj\nlet user = {\n    name: 'Gope'\n};\n\n// age not allow any update but name does\nObject.defineProperty(user, 'age', {\n    value: 4,\n    writable: false\n})\n\nuser.name = 'Lakshman'\nuser.age = 5;\n\nconsole.log(user); // TypeError: Cannot assign to read only property 'age' of object '#\u003cObject\u003e'\n ```\n \n  \u003ca name=\"rename\"\u003e\u003c/a\u003e\u003ca name=\"1.7\"\u003e\u003c/a\u003e\n- [1.7](#rename) **rename**: Rename multiple files extentions at once by a command (Just for Win).\n \n ```javascript \n  Get-ChildItem *.css | Rename-Item -NewName { $_.name -Replace '\\.css','.scss' }\n ```\n\n  \u003ca name=\"majority\"\u003e\u003c/a\u003e\u003ca name=\"1.8\"\u003e\u003c/a\u003e\n- [1.8](#majority) **majority**: Find Majority Element.\n  \n```javascript\nfunction majorityElement(arr) {\n    let count = 0, candidate = null;\n\n    for (let num of arr) {\n        if (count === 0) candidate = num;\n        count += (num === candidate) ? 1 : -1;\n    }\n\n    return candidate;\n}\n\n// Time complexity: O(n)\n// Space complexity: O(1)\n\nconst arr = [3, 2, 3, 4, 3, 1, 6, 6, 7, 8, 6, 9, 6];\nconsole.log(majorityElement(arr)); // Output: 6\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flgope%2Fjavascript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flgope%2Fjavascript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flgope%2Fjavascript/lists"}