Next-Generation Javascript | Modern Javascript Refresher

I am Developer, Artist and trying my luck on blogging as well. Well I am Ambitious, Passionate towards Learning, The Night Owl, And I Like challenges...
Search for a command to run...

I am Developer, Artist and trying my luck on blogging as well. Well I am Ambitious, Passionate towards Learning, The Night Owl, And I Like challenges...
No comments yet. Be the first to comment.
This course teaches you javascript , from the ground up, step by step by diving into all the core basics, exploring tons of examples and also introducing you to advanced concepts as well.
In this article, we will see how can we generate an SSL certificate for our development server. And later on, we will see how can we use that certificate inside our application. Let's Create a Demo App in Express js To create a new npm project, let's...
Post #2 in the Complete Prompt Engineering Series Welcome back! In What is Prompt Engineering? A Complete Introduction, you learned what prompt engineering is and why it matters. Now we're going deeper: understanding the engine under the hood. You do...

Welcome to the future of human-AI collaboration. If you're reading this in 2024-2025, you're witnessing a fundamental shift in how humans interact with machines—and prompt engineering is your passport to this new world. The Definition: What Exactly I...
In this post, we’ll walk through the anatomy of a great prompt, illustrate every step with vivid examples, and even peek under the hood to see what happens technically when you hit “send.” By the end, you’ll be able to craft prompts that unlock the f...

What is GenAI and Why Does Prompting Matter? If you’ve ever wondered how people interact with AI tools, or why some folks seem to get exactly what they want from tools like ChatGPT while others receive confusing or generic responses, this article is ...

Let’s be honest—being a developer isn’t just about writing code. It’s about solving problems, dealing with burnout, handling meetings, chasing deadlines, and finding time to learn, debug, and ship. But in the middle of this chaos, one simple habit ca...

In this article, I provided a brief introduction to some core next-gen JavaScript features, of course focusing on the ones you'll see the most in this courseHere's a quick summary!
Read more about let : https://developer.mozilla.org/en-US/ docs/Web/JavaScript/Reference/Statements/let Read more about const : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const
let and const basically replace var You use let instead of var and const instead of var if you plan on never re-assigning this "variable" (effectively turning it into a constant therefore).
Read more: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions
Arrow functions are a different way of creating functions in JavaScriptBesides a shorter syntax, they offer advantages when it comes to keeping the scope of the this keyword (see here).
Arrow function syntax may look strange but it's actually simple.
function callMe(name) {
console.log(name);
}
which you could also write as:
const callMe = function(name) {
console.log(name);
}
becomes:
const callMe = (name) => {
console.log(name);
}
When having no arguments, you have to use empty parentheses in the function declaration:
const callMe = () => {
console.log('Max!');
}
When having exactly one argument, you may omit the parentheses:
const callMe = name => {
console.log(name);
}
When just returning a value, you can use the following shortcut:
const returnMe = name => name
That's equal to:
const returnMe = name => {
return name;
}
In React projects (and actually in all modern JavaScript projects), you split your code across multiple JavaScript files - so-called modulesYou do this, to keep each file/ module focused and manageable.
To still access functionality in another file, you need export (to make it available) and import (to get access) statements.
You got two different types of exports: default (unnamed) and named exports:
default => export default ...;
named => export const someData = ...;
You can import default exports like this:
import someNameOfYourChoice from './path/to/file.js';
Surprisingly, someNameOfYourChoice is totally up to you. Named exports have to be imported by their name:
import { someData } from './path/to/file.js';
A file can only contain one default and an unlimited amount of named exportsYou can also mix the one default with any amount of named exports in one and the same file. When importing named exports, you can also import all named exports at once with the following syntax:
import * as upToYou from './path/to/file.js';
upToYou is - well - up to you and simply bundles all exported variables/functions in one JavaScript objectFor example, if you
export const someData = ..(/path/to/file.js )
you can access it on upToYou like this:
upToYou.someData
Classes are a feature which basically replace constructor functions and prototypesYou can define blueprints for JavaScript objects with them
Like this:
class Person {
constructor () {
this.name = 'Max';
}
}
const person = new Person();
console.log(person.name); // prints 'Max'
In the above example, not only the class but also a property of that class (=> name ) is definedThey syntax you see there, is the "old" syntax for defining propertiesIn modern JavaScript projects (as the one used in this course), you can use the following, more convenient way of defining class properties:
class Person {
name = 'Max';
}
const person = new Person();
console.log(person.name); // prints 'Max'
You can also define methodsEither like this:
class Person {
name = 'Max';
printMyName () {
console.log(this.name); // this is required to refer to the class!
}
}
const person = new Person();
person.printMyName();
Or like this:
class Person {
name = 'Max';
printMyName = () => {
console.log(this.name);
}
}
const person = new Person();
person.printMyName();
The second approach has the same advantage as all arrow functions have: The this keyword doesn't change its reference. You can also use inheritance when using classes:
class Human {
species = 'human';
}
.
class Person extends Human {
name = 'Max';
printMyName = () => {
console.log(this.name);
}
}
.
const person = new Person();
person.printMyName();
console.log(person.species); // prints 'human'
The spread and rest operators actually use the same syntax:
..
Yes, that is the operator - just three dotsIt's usage determines whether you're using it as the spread or rest operator.
The spread operator allows you to pull elements out of an array (=> split the array into a list of its elements) or pull the properties out of an objectHere are two examples:
const oldArray = [1, 2, 3];
const newArray = [...oldArray, 4, 5]; // This now is [1, 2, 3, 4, 5];
Here's the spread operator used on an object:
const oldObject = {
name: 'Max'
};
const newObject = {
...oldObject,
age: 28
};
newObject would then be
{
name: 'Max',
age: 28
}
The spread operator is extremely useful for cloning arrays and objectsSince both are reference types (and not primitives), copying them safely (i.epreventing future mutation of the copied original) can be trickyWith the spread operator you have an easy way of creating a (shallow!) clone of the object or array
Destructuring allows you to easily access the values of arrays or objects and assign them to variables. Here's an example for an array:
const array = [1, 2, 3];
const [a, b] = array;
console.log(a); // prints 1
console.log(b); // prints 2
console.log(array); // prints [1, 2, 3]
And here for an object:
const myObj = {
name: 'Max',
age: 28
}
const {name} = myObj;
console.log(name); // prints 'Max'
console.log(age); // prints undefined
console.log(myObj); // prints {name: 'Max', age: 28}
Destructuring is very useful when working with function argumentsConsider this example:
const printName = (personObj) => {
console.log(personObj.name);
}
printName({name: 'Max', age: 28}); // prints 'Max'
Here, we only want to print the name in the function but we pass a complete person object to the functionOf course this is no issue but it forces us to call personObj.name inside of our functionWe can condense this code with destructuring:
const printName = ({name}) => {
console.log(name);
}
printName({name: 'Max', age: 28}); // prints 'Max')
We get the same result as above but we save some code By destructuring, we simply pull out the name property and store it in a variable/ argument named name which we then can use in the function body.
Not really next-gen JavaScript, but also important: JavaScript array functions like map() , filter() , reduce() etc.
You'll see me use them quite a bit since a lot of React concepts rely on working with arrays (in immutable ways).
The following page gives a good overview over the various methods you can use on the array prototype - feel free to click through them and refresh your knowledge as required: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
Particularly important in this course are:
map() => https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map
find() => https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find
findIndex() => https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex
filter() => https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
reduce() => https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce?v=b
concat() => https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat?v=b
slice() => https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice
splice() => https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice