{"id":16619626,"url":"https://github.com/javazakariae/javascript-notes-for-java-developers","last_synced_at":"2025-10-06T23:48:02.031Z","repository":{"id":108181234,"uuid":"296817757","full_name":"JavaZakariae/javascript-notes-for-java-developers","owner":"JavaZakariae","description":"Repository that contains my notes about javascript","archived":false,"fork":false,"pushed_at":"2020-10-10T14:42:08.000Z","size":170,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-10T16:41:47.117Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/JavaZakariae.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":"2020-09-19T08:06:29.000Z","updated_at":"2020-10-10T14:42:10.000Z","dependencies_parsed_at":null,"dependency_job_id":"8f25ec29-1ef5-4969-8f65-309d57101338","html_url":"https://github.com/JavaZakariae/javascript-notes-for-java-developers","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/JavaZakariae/javascript-notes-for-java-developers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JavaZakariae%2Fjavascript-notes-for-java-developers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JavaZakariae%2Fjavascript-notes-for-java-developers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JavaZakariae%2Fjavascript-notes-for-java-developers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JavaZakariae%2Fjavascript-notes-for-java-developers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JavaZakariae","download_url":"https://codeload.github.com/JavaZakariae/javascript-notes-for-java-developers/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JavaZakariae%2Fjavascript-notes-for-java-developers/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263550754,"owners_count":23478866,"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":[],"created_at":"2024-10-12T02:42:26.289Z","updated_at":"2025-10-06T23:47:56.999Z","avatar_url":"https://github.com/JavaZakariae.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# javascript-notes for Java Developers\nThis is a repository that contains my notes about javascript, as a Java Developer I omitted many part of the javascript fundamentals for similarities reasons between java and Js. \n\nTo learn more about Javascript from wikipedia, visit the following [link](https://en.wikipedia.org/wiki/JavaScript#Weakly_typed).\n\n## Types\n- In Javascript, we don't declare the type of the data, for example we can declare and initialize a number variable like that `var n=1`, later in the program we can also change the type of the variable `n=\"nowitisastringvariable\"`. In java for example we need to declare it as follows: `int n=1`, later in the program we can't change the type of `n`.\n- Javascript is a dynamically typed language, to learn more, check the following links: [1](https://stackoverflow.com/questions/1517582/what-is-the-difference-between-statically-typed-and-dynamically-typed-languages), [2](https://android.jlelse.eu/magic-lies-here-statically-typed-vs-dynamically-typed-languages-d151c7f95e2b).\n\nThere are two categories of javascript data, the primitive data types and the complex data types. \n\n## Primitive Values \n- number: one type for decimals and floats, `var n=3.14`.\n- string: `\"str1\"`, `'str2'`, \\`str3\\`\n- boolean: true or false\n- undefined: When we create a variable without assigning a value to it, its value will be undefined, its type also will be undefined.\n- null: means an empty value, `var n=null`, the value of n will be null and the type of `n` will be object.\n- Primitives types are passed by value:\n\n    \u003cimg src=\"resources/passedbyvalue.png\"\u003e\n\n\n## Complex Values \nThere are two types in this category, arrays and objects.\n- array: `[1,'str1',true]`, arrays are `0` indexed, they can contains heterogenous types, objects type included: `[1,'str1',true, {key1: 1.5}]` .\n- object: `{key1:\"value1\", key2: 1.5, key3: true}`\n- Complex types are passed by reference:\n\n    \u003cimg src=\"resources/passedbyreference.png\"\u003e\n\n\n## NaN\n- Returned anytime a method expect a number input, and the caller pass a non number, the following expression will return `NaN`: `Math.sqrt('Mehdi the special one')`\n- `typeof NaN` will return number.\n- To check if a given value is of type NaN, we can use the function `isNaN(Math.sqrt('Mehdi the special one))`.\n- keep in mind that `console.log(NaN == NaN)` will result to false.\n\n\n## Comparison Operators\n- `45 == 45` will return true, we check if the two are equal.\n- `45 === \"45\"` will return false, we check if both are equal and their type is the same, it is called the strict equal.\n- `5 != \"5\"` will return false, we check if the two numbers are not equal.\n- `5 !== \"5\"` will return true, we check if the two numbers are not equal or they don't have the same type.\n\n## Functions\n- function declaration:\n    ```\n        function functionName(param1, param2){\n            //body of the function\n            // the possibility to return a value\n            //the returned value can be of any type, even a function\n        }\n    ```\n- a return keyword without an expression after it, will cause the function to return undefined, the samething happens when we don't have a return statement.\n- If we pass too many parameters to a function, the extra ones are ignored, if we pass too few, the missing parameters get assigned undefined as a value.\n\n## Strong, Weak, Dynamic ans Static language\n- JavaScript is a weakly dynamic language, to read more about that, check the following links: [1](https://android.jlelse.eu/magic-lies-here-statically-typed-vs-dynamically-typed-languages-d151c7f95e2b), [2](https://en.wikipedia.org/wiki/Strong_and_weak_typing), [3](https://www.i-programmer.info/programming/theory/1469-type-systems-demystified-part2-weak-vs-strong.html).\n\n\u003cimg src=\"resources/languageTypes.png\"\u003e\n\n## Type Coercion\n### Explicit Coercion: \n- `String(10)` will return a string data type.\n- `Number(\"1\")` will return a number data type.\n- `Boolean(\"string\")`\n\n### Implicit Coercion: \n- performed by javascript behind the scene, `\"5\"/2` will return `2.5`.\n\n## Scopes\n- Global scope, local scope, block scope, function hoising, function scope, nested scopes\n- Using the `var` keyword, we can create two variables with the same name\n\n    \u003cimg src=\"resources/scopes.PNG\"\u003e\n\n- As we can see in the above example, the variable `one` is a global variable and can be accessed from anywhere, the `number` variable declared with `let` keyword is local to its function and can not be accessed globally, the variable `three` even with the `var` keyword can not be accessed globally because its scope is the same as the function `innerFunction()` and can only be accessed inside the getApi function. For more details about scopes, visit the following links, [1](https://stackoverflow.com/questions/762011/whats-the-difference-between-using-let-and-var), [2](https://medium.com/@vincent.bocquet/var-let-const-en-js-quelles-diff%C3%A9rences-b0f14caa2049).\n\n- For those reasons, it is recommended to use the `let` or the `const` keywords whenever possible.\n\n## Closures\n- A closure gives you access to an outer function's scope from an inner function, for more details check [1](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures), [2](https://www.pierre-giraud.com/javascript-apprendre-coder-cours/closure/).\n- More on closure, [here](https://medium.com/@prashantramnyc/javascript-closures-simplified-d0d23fa06ba4).\n\n## This\n- Article about this keyword: [1](https://blog.invivoo.com/utiliser-loperateur-this-javascript/), [2](https://medium.com/@vincent.bocquet/comprendre-lop%C3%A9rateur-this-en-javascript-41f8630141d4), [3](https://stackoverflow.com/questions/3127429/how-does-the-this-keyword-work). \n\n## ES6\n### var keyword\n- If a variable is declared inside a function, this variable can not be accessed outside the function. We say the variable has a function scope. In case, it is declared inside a block, we say that is block scoped variable and it can be accessed outside of the scope\n\n    \u003cimg src=\"resources/let.PNG\"\u003e\n\n### let keyword\n- We can't declare two variable with the same name inside the same scope, the variable declared with let is said to be block scoped, an example to make it more clear.\n    [let](resources/let.PNG)\n\n### Arrow functions\n- Map this keyword without using the bind method.\n- Shorter and concise code.    \n- Code hard to read.\n- Two ways to write arrow functions\n\n    \u003cimg src=\"resources/arrow-function.png\"\u003e\n\n## Template literals\n- [Example on template literals](js\\es6\\template-literals.js)\n\n## destructuring\n- [arrays](https://github.com/JavaZakariae/javascript-notes-for-javadevelopers/blob/master/js/es6/destructuring-arrays.js)\n- [objects](https://github.com/JavaZakariae/javascript-notes-for-javadevelopers/blob/master/js/es6/destructuring-objects.js)\n- [functions](https://github.com/JavaZakariae/javascript-notes-for-javadevelopers/blob/master/js/es6/destructuring-functions.js)\n\n## for loop\n- [Examples](https://github.com/JavaZakariae/javascript-notes-for-javadevelopers/blob/master/js/es6/for-iteration.js)\n\n    \u003cimg src=\"resources/forloop.png\"\u003e\n\n\n## Arrays utilities methods\n- [Examples](https://github.com/JavaZakariae/javascript-notes-for-javadevelopers/blob/master/js/es6/arrays.js)  \n\n\n## Spread operator\n- [Examples](https://github.com/JavaZakariae/javascript-notes-for-javadevelopers/blob/master/js/es6/spread-operator.js) \n\n## Promise\n- Articles about Promise: [medium](https://medium.com/@kevinyckim33/what-are-promises-in-javascript-f1a5fc5b34bf#:~:text=In%20short%2C%20a%20Promise%20is,catch%20to%20handle%20failure%20cases.),[mozilla](https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Objets_globaux/Promise),[about Promise race](https://www.javascripttutorial.net/es6/javascript-promise-race/),[4](https://www.freecodecamp.org/news/javascript-promises-explained/), [promise-api](promise-api).\n- [Examples](https://github.com/JavaZakariae/javascript-notes-for-javadevelopers/blob/master/js/es6/promise.js) \n- [async and await](https://github.com/JavaZakariae/javascript-notes-for-javadevelopers/blob/master/js/es6/async-await.js) \n- async and await:[]() \n## Articles\n- [Semicolon in Js](https://flaviocopes.com/javascript-automatic-semicolon-insertion/).\n- Expression Vs Statement: [1](https://stackoverflow.com/questions/12703214/javascript-difference-between-a-statement-and-an-expression#:~:text=%E2%80%9CWherever%20JavaScript%20expects%20a%20statement,the%20argument%20of%20a%20function.%E2%80%9D), [2](https://medium.com/launch-school/javascript-expressions-and-statements-4d32ac9c0e74), [3](https://2ality.com/2012/09/expressions-vs-statements.html).\n- Is javascript an interpreted or compiled language: [1](https://medium.com/@almog4130/javascript-is-it-compiled-or-interpreted-9779278468fc), [2](https://blog.sessionstack.com/how-javascript-works-inside-the-v8-engine-5-tips-on-how-to-write-optimized-code-ac089e62b12e), [3](https://stackoverflow.com/questions/9623813/is-javascript-compiled-or-an-interpreted-language).\n- Function hoising [1](https://developer.mozilla.org/fr/docs/Glossaire/Hoisting), [2](https://scotch.io/tutorials/understanding-hoisting-in-javascript#:~:text=Hoisting%20is%20a%20JavaScript%20mechanism,scope%20is%20global%20or%20local.), [3](http://adripofjavascript.com/blog/drips/variable-and-function-hoisting.html).\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjavazakariae%2Fjavascript-notes-for-java-developers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjavazakariae%2Fjavascript-notes-for-java-developers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjavazakariae%2Fjavascript-notes-for-java-developers/lists"}