aliyev.dev
17 subscribers
53 photos
2 videos
1 file
41 links
JavaScript Tips and Tricks

Follow us:
YouTube: youtube.com/@developer_nijat
TikTok: tiktok.com/@developer.nijat
Facebook: fb.com/groups/1298499510834490
Website: aliyev.dev
Download Telegram
Channel name was changed to «Aliyev's DevTales»
🔄 JavaScript Tip: Embrace the power of 'Array.from()' to convert array-like objects or iterable into an array. It's a handy utility method for working with various data structures. Example:

// Convert string to array
const string = 'hello';
const charArray = Array.from(string);

// Convert NodeList to array (e.g., from querySelectorAll)
const elements = document.querySelectorAll('.myClass');
const elementArray = Array.from(elements);
#JavaScript #ArrayFrom #CodingTips
JavaScript tip: Map arrays with more shorthand way
📌 Consider using the useReducer hook instead of having more than 5 useState calls to manage complex state logic in a more organized manner.

In the refactored version, useReducer consolidates state management, making the component code cleaner and more maintainable. Actions are dispatched with specific types, and the reducer handles state updates accordingly.

#javascript #ReactJS #React #reacthooks #useReducer #refactoring #cleancode #statemanagement #developernijat #aliyevsdevtales
1
🛑 JavaScript Tip: Be mindful of 'hoisting' when declaring variables with 'var'. Variables declared with 'var' are hoisted to the top of their scope, which can lead to unexpected behavior. Consider using 'let' or 'const' for more predictable results. Example:

console.log(name); // undefined
var name = 'John';

// Using let or const to avoid hoisting issues
console.log(age); // ReferenceError: age is not defined
let age = 25;
#JavaScript #Hoisting #CodingTips
🧠 JavaScript Tip: Use the 'Array.prototype.reduce()' method to transform, filter, or accumulate values in an array. It's a powerful and versatile method for processing arrays with a single callback function. Example:

const numbers = [1, 2, 3, 4, 5];

// Summing up array elements with reduce
const sum = numbers.reduce((accumulator, currentValue) => accumulator + currentValue, 0);
console.log(sum); // 15
#JavaScript #ArrayReduce #CodingTips
EN: Google Developers Codelabs provide a guided, tutorial, hands-on coding experience. Most codelabs will step you through the process of building a small application, or adding a new feature to an existing application. They cover a wide range of topics such as Android Wear, Google Compute Engine, ARCore, and Google APIs on iOS.

AZ: Google Developers Codelabs təlimatlı, təlimatçı, praktiki kodlaşdırma təcrübəsi təqdim edir. Əksər kod laboratoriyaları kiçik proqram yaratmaq və ya mövcud proqrama yeni funksiya əlavə etmək prosesində sizə addım atacaq. Onlar iOS-da Android Wear, Google Compute Engine, ARCore və Google API kimi geniş mövzuları əhatə edir.

https://codelabs.developers.google.com/

#google #codelabs #googledevelopers #android #flutter #learn #coding #programming #AndroidWear #arcore #GoogleAPIs #ios #developernijat #aliyevsdevtales
Here's a brief guide on using parallel processing in Node.js:

Using the cluster module for parallel processing:

The cluster module in Node.js allows forking processes to take advantage of multiple CPU cores, enabling parallel processing. Here's an example:

const cluster = require('cluster');
const http = require('http');
const numCPUs = require('os').cpus().length;

if (cluster.isMaster) {
console.log(`Master ${process.pid} is running`);

// Fork workers for each CPU core
for (let i = 0; i < numCPUs; i++) {
cluster.fork();
}

cluster.on('exit', (worker, code, signal) => {
console.log(`Worker ${worker.process.pid} died`);
});
} else {
// Workers can share any TCP connection
// In this case, an HTTP server
http.createServer((req, res) => {
res.writeHead(200);
res.end('Hello, World!\n');
}).listen(8000);

console.log(`Worker ${process.pid} started`);
}
This code demonstrates how the cluster module creates multiple worker processes, each handling incoming HTTP requests.

Using the async library for parallel operations:

Another approach is to use libraries like async to perform parallel operations. Here's an example:

const async = require('async');

// Simulated asynchronous tasks
const task1 = (callback) => {
setTimeout(() => {
console.log('Task 1 completed');
callback(null, 'Result of Task 1');
}, 1000);
};

const task2 = (callback) => {
setTimeout(() => {
console.log('Task 2 completed');
callback(null, 'Result of Task 2');
}, 500);
};

// Parallel execution of tasks
async.parallel([task1, task2], (err, results) => {
if (err) {
console.error('Error:', err);
return;
}
console.log('All tasks completed');
console.log('Results:', results);
});
In this example, async.parallel runs task1 and task2 in parallel and collects their results.

These examples demonstrate two different ways to achieve parallel processing in Node.js: using the cluster module for managing multiple processes and using a library like async for handling parallel asynchronous tasks within a single process.
async.parallel and Promise.all are two different approaches to handling parallel asynchronous operations in JavaScript, but they serve a similar purpose.

async.parallel:
- async.parallel is a function provided by the async library in Node.js. It's used to execute multiple asynchronous tasks simultaneously and collect their results.
- It accepts an array of functions (tasks) and a final callback function.
- It executes all tasks in parallel and waits for all tasks to complete before calling the final callback with the results.
- It's suitable for scenarios where you have multiple asynchronous tasks to perform simultaneously.

Example using async.parallel:
const async = require('async');

const task1 = (callback) => {
setTimeout(() => {
console.log('Task 1 completed');
callback(null, 'Result of Task 1');
}, 1000);
};

const task2 = (callback) => {
setTimeout(() => {
console.log('Task 2 completed');
callback(null, 'Result of Task 2');
}, 500);
};

async.parallel([task1, task2], (err, results) => {
if (err) {
console.error('Error:', err);
return;
}
console.log('All tasks completed');
console.log('Results:', results);
});
`Promise.all:
-
Promise.all is a built-in JavaScript method that takes an iterable (e.g., an array) of promises and returns a single Promise that resolves when all of the input promises have resolved.
- It's commonly used with native promises or Promise-based APIs in modern JavaScript.
- It's ideal when you have multiple promises to execute in parallel and need to await all of them to complete.

Example using Pr
omise.all:
const task1 = new Promise((resolve) => {
setTimeout(() => {
console.log('Task 1 completed');
resolve('Result of Task 1');
}, 1000);
});

const task2 = new Promise((resolve) => {
setTimeout(() => {
console.log('Task 2 completed');
resolve('Result of Task 2');
}, 500);
});

Promise.all([task1, task2])
.then((results) => {
console.log('All tasks completed');
console.log('Results:', results);
})
.catch((err) => {
console.error('Error:', err);
});
In summary, async.parallel is a method provided by the async library specifically designed for parallel execution of multiple tasks, while Promise.all is a native JavaScript method for handling multiple promises in parallel, commonly used with native promises or Promise-based APIs in JavaScript. Both are useful for managing parallel asynchronous operations, but Promise.all is more native to modern JavaScript environments.
An alternative to setInterval() in JavaScript is using setTimeout() recursively to achieve a similar effect of interval-based execution.

Here's an example of how you can create a function that executes repeatedly with a delay using setTimeout():

function repeatAction() {
// Perform your action here
console.log('Action performed');

// Schedule the next execution after a delay
setTimeout(repeatAction, 3000); // Set the delay in milliseconds (e.g., 3000ms = 3 seconds)
}

// Start the initial execution
repeatAction();
This approach involves calling setTimeout() inside the function itself to create a loop-like behavior with a delay between each execution, achieving similar functionality to setInterval().
📣 The good news is that JavaScript is now getting grouping methods so you won’t have to anymore. Object.groupBy and Map.groupBy are new methods that will make grouping easier and save us time or a dependency.

#JS #javascript #coding #programming #developernijat #aliyevsdevtales #object #GROUPBY
22 Frontend Certifications for Web Developers

🌱 HTML + CSS

1. Introduction to Front-End Development
This introductory course will help you learn front-end development from scratch as well as the important tools and technologies in it.

👉 https://www.simplilearn.com/front-end-developer-free-course-skillup

2. Front-End Development - HTML
Learn front-end development for free to gain fundamental knowledge of HTML and kick-start your Front front-end development career.

👉 https://www.mygreatlearning.com/academy/learn-for-free/courses/front-end-development-html

3. CSS, CSS Box Model, and CSS Projects
This CSS Tutorial gives you an introduction to CSS, CSS Box Model, and CSS Projects.

👉 https://www.mygreatlearning.com/academy/learn-for-free/courses/css-tutorial

4. CSS Essential Training
In this hands-on course, you will learn the concepts that form the foundation of CSS, explaining what you need to know to tweak existing CSS and write your own.

👉 https://www.linkedin.com/learning/css-essential-training-revision-q4-2019

5. Modern HTML & CSS (Including SASS)
Build modern responsive websites & UIs with HTML5, CSS3 & Sass! Learn Flex & CSS Grid.

👉 https://www.udemy.com/course/modern-html-css-from-the-beginning

6. CSS - The Complete Guide
Learn CSS for the first time, brush up your CSS skills, and dive in even more.

👉 https://www.udemy.com/course/css-the-complete-guide-incl-flexbox-grid-sass/

7. Responsive Web Design
You'll learn the languages that developers use to build web: HTML for content, and CSS for design.

👉 https://www.freecodecamp.org/learn/2022/responsive-web-design/

8. CSS Skills Certification Test
The test covers topics like exploring Cascading and Inheritance, exploring text styling fundamentals, understanding the use of layouts, and the boxing of elements, among others.

👉 https://www.hackerrank.com/skills-verification/css

🚀 JavaScript

9. Introduction to JavaScript
This course will introduce you to the basics of the JavaScript programming language and the platforms used to code the language.

👉 https://www.mygreatlearning.com/academy/learn-for-free/courses/introduction-to-javascript

10. Learn Javascript Basics
You will learn skills to build simple programs and web applications and customize web pages.

👉 https://www.simplilearn.com/learn-javascript-basics-free-course-skillup

11. JavaScript Algorithms and Data Structures
You'll learn the fundamentals of JavaScript, such as variables, arrays, objects, loops, and functions.

You'll put that knowledge to use by writing algorithms to manipulate strings, factorial numbers, etc.

👉 https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/

12. JavaScript Essentials 1 (JSE)
Learn the essentials of JavaScript and computer programming. Learn how interactive web and mobile apps are created with JavaScript – and learn to program your own.

👉 https://www.netacad.com/courses/programming/javascript-essentials-1

13. JavaScript Projects
This course will guide you through three apps that will help you develop similar ones in the future.

👉 https://www.mygreatlearning.com/academy/learn-for-free/courses/javascript-projects

14. Learn to program with JavaScript
Build a strong foundation in web development by learning JavaScript, one of the major programming languages on the web.

👉 https://openclassrooms.com/en/courses/5664271-learn-programming-with-javascript

15. JavaScript Essential Training
Through practical examples and mini-projects, you will boost your understanding of JS piece by piece, from core principles like variables, data types, conditionals, and functions through advanced topics including loops, closures, and DOM scripting.

👉 https://www.linkedin.com/learning/javascript-essential-training-3/welcome

16. JavaScript Skills Certification Test (Basic)
The test covers topics like Functions, Currying, Hoisting, Scope, Inheritance, Events, and Error Handling.

👉 https://www.hackerrank.com/skills-verification/javascript_basic
17. JavaScript Skills Certification Test (Intermediate)
The test covers topics like Design Patterns, Memory management, concurrency models, and event loops.

👉 https://www.hackerrank.com/skills-verification/javascript_intermediate

⚛️ React JS

18. React JS for Beginners
This course is taught hands-on by experts. Learn prerequisites of HTML, CSS, and Javascript. Also, learn to create a React App.

👉 https://www.mygreatlearning.com/academy/learn-for-free/courses/react-js-tutorial

19. React JavaScript - Fundamentals to Coding
You will learn to set up your first React environment, components, keys, and props. It also discusses folder structure, CSS styling, and React operators.

👉 https://alison.com/course/react-javascript-fundamentals-to-coding-and-new-beginnings

20. Front-End Development Libraries
You'll learn how to add logic to your CSS styles, extend them with Sass, and work with Bootstrap.

Later, you'll build a shopping cart and other applications to learn how to create powerful SPAs with React and Redux.

👉 https://www.freecodecamp.org/learn/front-end-development-libraries/

21. React Essential Training
You will learn how to set up Chrome tools for React; create new components; work with the built-in Hooks in React; use the Create React App to run tests and more.

👉 https://www.linkedin.com/learning/react-js-essential-training-14836121

22. React Skills Certification Test
The test covers topics like Basic Routing, Rendering Elements, State Management (Internal Component State), Handling Events, ES6 and JavaScript, and Form Validation.

👉 https://www.hackerrank.com/skills-verification/react_basic

Source: https://dev.to/madza/26-frontend-certifications-for-web-developers-4md7

Follow us:
YouTube: youtube.com/@developer_nijat
Telegram: t.me/js_az
TikTok: tiktok.com/@developer.nijat
Facebook: facebook.com/groups/1298499510834490


#js #javascript #React #react #ReactJS #reactjs #web #webdev #developer #programming #webdeveloper #webdevelopment #learnprogramming #developernijat #aliyevsdevtales
JavaScript's Date object provides several methods to work with dates. Here are some common methods along with examples:

### Creating a Date Object:
// Create a new Date object representing the current date and time
const currentDate = new Date();

// Create a new Date object for a specific date and time
const specificDate = new Date('2023-11-20T08:30:00');
### Getting Components of a Date:
const date = new Date();

// Get the year, month, day, hour, minute, second, and millisecond
const year = date.getFullYear();
const month = date.getMonth(); // Months are zero-based (0-11)
const day = date.getDate();
const hours = date.getHours();
const minutes = date.getMinutes();
const seconds = date.getSeconds();
const milliseconds = date.getMilliseconds();
### Setting Components of a Date:
const date = new Date();

// Set year, month, day, hour, minute, second, and millisecond
date.setFullYear(2023);
date.setMonth(10); // Month: 0-11 (November is 10)
date.setDate(20);
date.setHours(8);
date.setMinutes(30);
date.setSeconds(0);
date.setMilliseconds(0);
### Formatting Dates:
const date = new Date();

// Format date components as a string
const dateString = date.toDateString(); // "Wed Nov 20 2023"
const timeString = date.toTimeString(); // "08:30:00 GMT+0000 (Coordinated Universal Time)"
const localString = date.toLocaleString(); // "11/20/2023, 8:30:00 AM" (depends on local settings)
### Operations on Dates:
const date = new Date();

// Get the number of milliseconds since January 1, 1970, 00:00:00 UTC
const millisecondsSinceEpoch = date.getTime();

// Calculate the difference between two dates
const date1 = new Date('2023-11-20');
const date2 = new Date('2023-11-25');
const differenceInMilliseconds = date2 - date1;
const differenceInSeconds = differenceInMilliseconds / 1000;
These methods cover the basics of working with dates in JavaScript. There are many more methods and functionalities available for handling dates, but these are some of the most commonly used ones.
DNS (Domain Name System), internetin əsas təşkilatçılarından biridir. DNS, insanların anlaya biləcəyi domain adlarını (məsələn, example.com) IP ünvanlarına çevirən bir hierarşik yapıdır. İnternetdə hər bir cihazın, saytın və ya hizmətin bir IP ünvanı vardır, lakin insanların bu numerik adresləri yadda saxlamağı çətin ola bilər. İşte burada DNS-in rolu başlayır.

DNS, istifadəçilərin domain adlarına daxil etdikləri veb ünvanlarını DNS serverlər vasitəsi ilə IP ünvanlarına tərcümə edir. Bu sistem, istifadəçilərin veb brauzerləri ilə serverlər arasında mürəkkəb numerik adreslər yerinə daha anlaşıqlı adları istifadə etmələrini təmin edir.

Bu sistem bir hiyerarxiya ilə təşkil olunmuşdur: domain adları, "top-level domain"lardan (TLD) başlayaraq daha aşağı səviyyələrə doğru (nümunə üçün, .com, .org, .net kimi) bölünür. Hər bir domain adı serveri, məsələn, .com domainində olan server, ona aid olan domain adlarının IP ünvanlarına tərcümə edilməsində kömək edir.

DNS, internetin fəal işləməsində əhəmiyyətli bir rol oynayaraq, istifadəçilərin vebdə asanlıqla dolaşmaq və saytlara çatmaq imkanını təmin edir.

Follow us:
YouTube: youtube.com/@developer_nijat
Telegram: t.me/js_az
TikTok: tiktok.com/@developer.nijat
Facebook: fb.com/groups/1298499510834490

#dns #network #INTERNET #web #developernijat #aliyevsdevtales
Here's the list of programming languages sorted by their creation year (TOP 19 popular):

1. C (1972) - Dennis Ritchie (United States - Bell Labs)
2. SQL (1974) - Donald D. Chamberlin and Raymond F. Boyce (United States - IBM)
3. Objective-C (1983) - Brad Cox and Tom Love (United States)
4. MATLAB (1984) - MathWorks (United States)
5. C++ (1985) - Bjarne Stroustrup (United States - Bell Labs)
6. Perl (1987) - Larry Wall (United States)
7. Haskell (1990) - Committee on Haskell 98 (United States and others through academic collaboration)
8. Python (1991) - Guido van Rossum (Netherlands)
9. R (1993) - Ross Ihaka and Robert Gentleman (New Zealand)
10. PHP (1994) - Rasmus Lerdorf (Denmark)
11. Java (1995) - James Gosling (United States - Sun Microsystems)
12. JavaScript (1995) - Brendan Eich (United States - Netscape Communications Corporation)
13. C# (2000) - Microsoft Corporation (United States)
14. Scala (2003) - Martin Odersky (Germany)
15. Rust (2010) - Graydon Hoare (Canada - Mozilla Research)
16. Go (2009) - Google (United States)
17. Kotlin (2011) - JetBrains (Russia)
18. TypeScript (2012) - Microsoft Corporation (United States)
19. Swift (2014) - Apple Inc. (United States)

Follow us:
YouTube: youtube.com/@developer_nijat
Telegram: t.me/js_az
TikTok: tiktok.com/@developer.nijat
Facebook: fb.com/groups/1298499510834490

#programming #programminglanguage #evaluation #history #developernijat #aliyevsdevtales