Skip to content

Commit 56f5658

Browse files
committed
Moar fixes
1 parent d2ce915 commit 56f5658

11 files changed

+171
-65
lines changed

Node_JavaScript_Programming/javascript-programming.md

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,9 +355,10 @@ To remove elements from an array in JavaScript, you can use the pop(), shift(),
355355
Using filter(): It creates a new array with elements that pass the test implemented by the provided function.
356356

357357
Looping Through an Array in JavaScript
358+
358359
You can loop through an array in JavaScript using various methods such as for loop, forEach(), for...of loop, and map() method. Here's a brief overview of each method:
359360

360-
Using for loop:
361+
Using `for` loop:
361362

362363
```js
363364
for (let i = 0; i < array.length; i++) {
@@ -568,4 +569,57 @@ You can also remove duplicates from an array of objects in JavaScript using the
568569
// Output: [{id: 1, name: 'John'}, {id: 2, name: 'Jane'}]
569570
```
570571

571-
This code uses the filter() method in combination with the findIndex() method to create a new array containing only the first occurrence of each unique object. The Set object and the filter() method provide effective ways to remove duplicates from an array of objects in JavaScript, each with its own advantages and considerations
572+
This code uses the filter() method in combination with the findIndex() method to create a new array containing only the first occurrence of each unique object. The Set object and the filter() method provide effective ways to remove duplicates from an array of objects in JavaScript, each with its own advantages and considerations
573+
574+
## Using Async and Await
575+
576+
To use async and await in JavaScript, you can follow these steps:
577+
578+
Declare an Async Function: Use the async keyword before a function to declare it as an async function. This means the function always returns a promise. For example:
579+
580+
async function myFunction() {
581+
return "Hello";
582+
}
583+
584+
Use the Await Keyword: Inside an async function, you can use the await keyword before a call to a function that returns a promise. This makes the code wait until the promise is resolved before continuing. For example:
585+
586+
let result = await myPromise;
587+
588+
Error Handling: You can use try...catch blocks to handle errors when using async and await.
589+
590+
To handle errors when using async and await in JavaScript, you can use the try...catch block. Here's how you can do it:
591+
592+
async function myFunction() {
593+
try {
594+
let result = await someAsyncTask();
595+
// Code to handle the result
596+
} catch (error) {
597+
// Code to handle the error
598+
}
599+
}
600+
601+
This allows you to catch and handle any errors that occur during the execution of the await-ed promise. As for the second part of your question, yes, async and await can be used with promises in JavaScript. The await keyword is used to wait for a promise to resolve, and it can only be used inside an async function. When used together, they provide a more readable and maintainable way to work with promises.
602+
603+
## Other different types of JavaScript files
604+
605+
- `.cjs` file extension
606+
607+
This is for CommonJS. CommonJS is a project that aims to standardize the module ecosystem for JavaScript outside of web browsers, such as on web servers or native desktop applications. It provides a specification for how modules should work and is widely used for server-side JavaScript with Node.js. CommonJS can be recognized by the use of the require() function and module.exports, while ES modules use import and export statements for similar functionality. The .cjs file extension is associated with CommonJS code, which is intended to allow JavaScript to be used in environments beyond a frontend web browser. It also allows JavaScript to be used in environments beyond a frontend web browser
608+
CommonJS is a module system for JavaScript used in server-side environments like Node.js.
609+
610+
- ``.mjs` file extension
611+
612+
The .mjs file extension is used to indicate that a JavaScript file uses the ECMAScript module format, providing a standardized way to organize and share JavaScript code across multiple files and projects. ES6 modules, which are denoted by the .mjs extension, offer several advantages over traditional .js files, including native support for ES6 modules, a clear distinction between modules and regular scripts, and improved compatibility with bundlers and build tools
613+
614+
The .mjs file extension is commonly used in Node.js for ECMAScript modules, providing a standardized way to organize and share JavaScript code across multiple files and projects. Some common use cases for .mjs files in Node.js include:
615+
616+
Native Support for ES6 Modules: The .mjs file extension leverages the native support for ES6 modules in modern JavaScript runtimes, allowing the use of the import and export keywords to define and use modules without the need for additional tools or transpilation
617+
618+
Clear Distinction Between Modules and Scripts: The use of .mjs file extension helps differentiate between modules and regular scripts, enabling developers to quickly identify and work with modules in their projects
619+
620+
Improved Compatibility with Bundlers and Build Tools: As the new module system gains popularity, bundlers and build tools have started to adopt native ES6 module support. Using the .mjs file extension ensures better compatibility with these tools, allowing for seamless integration into existing development workflows
621+
622+
- `.ejs` file extension
623+
624+
EJS, or Embedded JavaScript, is a simple templating language that allows the generation of HTML markup with plain JavaScript. It is commonly used as a template engine in Node.js to create HTML templates with minimal code and to inject data into an HTML template on the client side, producing the final HTML. EJS enables the embedding of JavaScript into HTML pages, and it is often used with Express, a web application framework for Node.js. EJS files typically use the .ejs file extension. To use EJS in a Node.js project, the EJS package can be installed via npm, and the templating engine can be set up with Express. EJS is known for its ease of use, as it allows the direct use of JavaScript to generate the desired HTML output. It also provides features such as partials and the ability to pass variables to views, making it a powerful tool for building web applications
625+

Node_JavaScript_Programming/make-an-nodemon-json-file.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,6 @@ Here is the `nodemon.json` File Structure:
4444
```
4545

4646
This is all the information I could find out about the file.
47+
48+
## Starting Nodemon
49+

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
# ProgrammerNotes
22

3-
This is a collection of Markdown notes written in Obsidian for programming and it includes notes on C, C++, using and configuring VSCode and many other things programming related. Anyone is welcome to contribute to this Markdown repository and make corrections.
3+
This is a collection of Markdown notes written in Obsidian for programming, coding, software engineering, software development and it includes notes on C, C++, using and configuring VSCode and many other things programming related. Anyone is welcome to contribute to this Markdown repository and make corrections.
4+
5+
Keep in mind these notes are Open Source. If I get it wrong, correct it in a PR or a issue or open a discussion.
6+
7+
Also, keep in mind these things are written just as I understand them, so they might be wrong. They have been copied from either hand written or typed notes I have written to help me in case I forgot how to do something in programming. If you use these things, Please verify that they work.
8+
9+
You don't have to use Obsidian to read this collection of notes, but it might help.

React_Development/react-development-notes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,5 @@ Other components:
3939
These components can be combined in different ways to form various tech stacks, such as the MEAN stack (MongoDB, Express, Angular, Node.js) or the LAMP stack (Linux, Apache, MySQL, PHP)
4040

4141
The choice of tech stack depends on the specific requirements of the project and the skills of the development team.
42+
43+
In the latest versions of React, and you are using JavaScript with React instead of TypeScript, you should be focused on using at least ES6 or ES2015 so that you have access to `import` and `export`

VSCode/create-a-tasks-json-file.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,23 @@ Here is the file structure:
1212

1313
```json
1414
{
15-
// See https://go.microsoft.com/fwlink/?LinkId=733558
16-
// for the documentation about the tasks.json format
17-
"version": "2.0.0",
18-
"tasks": [
19-
{
20-
"type": "",
21-
"label": "",
22-
"command": "",
23-
"args": "",
24-
"options": "",
25-
"problemMatcher": "",
26-
"group": "",
27-
"presentation": "",
28-
"dependsOn": "",
29-
"isBackground": "",
30-
}
31-
],
15+
// See https://go.microsoft.com/fwlink/?LinkId=733558
16+
// for the documentation about the tasks.json format
17+
"version": "2.0.0",
18+
"tasks": [
19+
{
20+
"type": "process",
21+
"label": "",
22+
"command": "",
23+
"args": [],
24+
"options": {},
25+
"problemMatcher": "",
26+
"group": "",
27+
"presentation": {},
28+
"dependsOn": "",
29+
"isBackground": true,
30+
}
31+
],
3232
}
3333
```
3434

WebDevelopment/beginning-webdev.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
11
# Web Development
22

3-
Web Development or WebDev.
3+
Web Development or WebDev as it is sometimes called, has a wide variety of subjects.
4+
5+
There is a LOT to learn and cover. I will do my best to cover a great deal of the basics. This is not intended to
6+
be an all encompassing guide or tutorial.
7+
8+
You should at this point start learn HTML, CSS and JavaScript programming if you haven't already. This is the base
9+
of Web Development. From there you can learn more advanced topics. There are lots of great resources to learn how
10+
to program in these.
11+
12+
You should become familiar with whatever web browsers yourself or your project will be displayed using, especially
13+
any devices you or your project may encounter.
14+
15+
## Choosing a editor or IDE for Web Development
16+
17+
This is a slightly controversial topic. But, just about any editor or IDE will be able to support languages used
18+
in web development. There are a few exceptions. There are a number of them that will work across different platforms
19+
like Linux, Windows and Mac. There are quite a few options, depending on whether you want to use the
20+
command line/shell/terminal/console to use your editor or use the GUI or user interface. A number of developers
21+
feel strongly about the editor or IDE they use. You should use the one that gets the job done for you.
22+
23+
This should go without saying, but you should try a few out before you settle on one and do not rely on what
24+
someone told you their editor or IDE is. You might or might not like the first editor or IDE you choose.
25+
26+
## Projects and what to make
27+
28+
## Mobile Web Development

about-manifest-json.md

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -34,43 +34,43 @@ At a minimum, a manifest file should contain the following manifest members: "na
3434
An example manifest.json,
3535

3636
```json
37-
{
38-
"name": "My Web App",
39-
"displayName": "My Web App",
40-
"background_color": "#ffffff",
41-
"dir": "ltr",
42-
"display": "standalone",
43-
"icons": [
44-
{
45-
"src": "icon-192.png",
46-
"sizes": "192x192",
47-
"type": "image/png"
48-
},
49-
{
50-
"src": "icon-512.png",
51-
"sizes": "512x512",
52-
"type": "image/png"
53-
}
54-
],
55-
"lang": "en-US",
56-
"orientation": "portrait",
57-
"start_url": "/",
58-
"id": "com.example.mywebapp",
59-
"scope": "/",
60-
"manifest_version": 2,
61-
"type": "web_app",
62-
"meta": {
63-
"author": "John Doe",
64-
"description": "A simple web app",
65-
"version": "1.0.0"
66-
},
67-
"dependencies": {
68-
"react": "^17.0.2",
69-
"react-dom": "^17.0.2"
70-
},
71-
"defaultWidth": 800,
72-
"defaultHeight": 600,
73-
"resizeX": true
37+
{
38+
"name": "My Web App",
39+
"displayName": "My Web App",
40+
"background_color": "#ffffff",
41+
"dir": "ltr",
42+
"display": "standalone",
43+
"icons": [
44+
{
45+
"src": "icon-192.png",
46+
"sizes": "192x192",
47+
"type": "image/png"
48+
},
49+
{
50+
"src": "icon-512.png",
51+
"sizes": "512x512",
52+
"type": "image/png"
53+
}
54+
],
55+
"lang": "en-US",
56+
"orientation": "portrait",
57+
"start_url": "/",
58+
"id": "com.example.mywebapp",
59+
"scope": "/",
60+
"manifest_version": 2,
61+
"type": "web_app",
62+
"meta": {
63+
"author": "John Doe",
64+
"description": "A simple web app",
65+
"version": "1.0.0"
66+
},
67+
"dependencies": {
68+
"react": "^17.0.2",
69+
"react-dom": "^17.0.2"
70+
},
71+
"defaultWidth": 800,
72+
"defaultHeight": 600,
73+
"resizeX": true
7474
}
7575
```
7676

@@ -86,6 +86,9 @@ The file typically includes information such as the application or extension nam
8686

8787
The manifest.json file affects web app performance by providing important metadata and configuration settings that help browsers and platforms understand and interact with the application, and by enabling the app to behave like a native app when installed on the user's device, which can improve user engagement and performance
8888

89-
Having a manifest.json file available to browsers on your website or web page, even if it's not an app or a Progressive Web App (PWA), can have an impact on SEO and performance. Search engines consider PWAs and websites with manifest.json files more favorably, which can lead to improved SEO. Additionally, using a manifest.json file can enhance user experience by allowing the website to be installed as a PWA, providing an immersive and engaging experience for users. It can also lead to increased user engagement and improved performance, as PWAs can cache website data and work offline, reducing the need to download data from the server repeatedly
89+
Having a `manifest.json` file available to browsers on your website or web page, even if it's not an app or a Progressive Web App (PWA), can have an impact on SEO and performance. Search engines consider PWAs and websites with `manifest.json` files more favorably, which can lead to improved SEO. Additionally, using a `manifest.json` file can enhance user experience by allowing the website to be installed as a PWA, providing an immersive and engaging experience for users. It can also lead to increased user engagement and improved performance, as PWAs can cache website data and work offline, reducing the need to download data from the server repeatedly
9090

91-
Therefore, while not strictly required for a traditional website, having a manifest.json file can still have positive effects on SEO and user experience
91+
Therefore, while not strictly required for a traditional website, having a manifest.json file can still have positive effects on SEO and user experience.
92+
93+
In Firefox, once the browser loads the page, if it locates a `manifest.json` file, you can open the browser console and click on the `Application`
94+
tab and click on Manifest. This section will display the properties you have set in the `manifest.json` file.

about-serviceworkers.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Service Workers
2+
3+
Most modern web browsers can utilize a Service Worker.
4+

configure-eslint.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,15 @@ Besides the .eslintrc file, ESLint also recognizes the following files as config
2929
- .eslintrc.yaml or .eslintrc.yml: These are YAML files to define the configuration structure.
3030

3131
- .eslintrc.json: This is a JSON file to define the configuration structure. ESLint’s JSON files also allow JavaScript-style comments.
32-
package.json: You can create an eslintConfig property in your package.json file and define your configuration there. If there are multiple configuration files in the same directory, ESLint only uses one.
32+
33+
- package.json: You can create an eslintConfig property in your package.json file and define your configuration there. If there are multiple configuration files in the same directory, ESLint only uses one.
3334

3435
The priority order is as follows: .eslintrc.js, .eslintrc.cjs, .eslintrc.yaml, .eslintrc.yml, .eslintrc.json, package.json
3536

3637
These files provide flexibility in how you can define and manage your ESLint configurations.
3738

39+
As you gain familiarity with ESLint, You should build a baseline configuration and store the rather than just rely on the defaults so that you can get to work easily on your project and store it somewhere handy so that you can copy and paste it into your project. If you work on various types of JavaScript projects and frameworks, you might even have several configurations you can rely on.
40+
3841
## Installing ESLint
3942

4043
Install the ESLint package in your project using npm:
@@ -66,4 +69,4 @@ There are plugins for ESLint. An ESLint plugin is an npm module that can contain
6669

6770
Each plugin is an npm module with a name in the format of eslint-plugin-<plugin-name>, such as eslint-plugin-react. Plugins can also provide additional environments, custom processors, and configurations
6871

69-
You should be able to easily find a list of awesome ESLint plugins, configs, etc. on GitHub
72+
You should be able to easily find a list of awesome ESLint plugins, configs, etc. on GitHub

configure-prettier.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
# Configuring Prettier
22

3-
Prettier is an opinionated code formatter that supports various languages. It enforces a consistent code style by parsing the code and reprinting it from scratch, taking the line length into account. It supports languages such as JavaScript (including experimental features), JSX, Angular, Vue, Flow, TypeScript, CSS, Less, SCSS, HTML, Ember/Handlebars, JSON, GraphQL, Markdown (including GFM and MDX v1), and Y
3+
Prettier is an opinionated code formatter that supports various languages. It enforces a consistent code style by parsing the code and reprinting it from scratch, taking the line length into account. It supports languages such as JavaScript (including experimental features), JSX, Angular, Vue, Flow, TypeScript, CSS, Less, SCSS, HTML, Ember/Handlebars, JSON, GraphQL, Markdown (including GFM and MDX v1).
44

5-
To configure Prettier, you can use a "prettier" key in your package.json file, a .prettierrc file written in JSON or YAML, a .prettierrc, .prettierrc.js or prettier.config.js file, or a .prettierrc.toml file, among other options.
5+
To configure Prettier, you can use a "prettier" key in your package.json file, a .prettierrc file written in JSON or YAML, prettierrc.js or prettier.config.js file, or a .prettierrc.toml file, among other options. According to recent Prettier documentation online, the current way to configure prettier is using a prettier.config.js file, but the other formats are still supported.
66

77
Prettier intentionally doesn’t support any kind of global configuration to ensure consistent behavior across different environments
88

99
Prettier also supports the use of plugins to add new languages or formatting rules. Official plugins include @prettier/plugin-php, @prettier/plugin-pug, @prettier/plugin-ruby, and many more. Community plugins are also available for a wide range of languages
10+
11+
If you're following along doing some Web Development, you will find this tool to help you format HTML, CSS, JavaScript.
12+
13+
## Extensions, Plugins
14+
15+
There are some ESLint plugins and extensions for VSCode.

0 commit comments

Comments
 (0)