https://github.com/mbrsagor/javascriptnote
JavaScript ES6 tutorial
https://github.com/mbrsagor/javascriptnote
es5-javascript es6-javascript javascript-es6-tutorial oop
Last synced: about 2 months ago
JSON representation
JavaScript ES6 tutorial
- Host: GitHub
- URL: https://github.com/mbrsagor/javascriptnote
- Owner: mbrsagor
- Created: 2020-02-20T04:15:38.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2025-01-22T18:19:53.000Z (5 months ago)
- Last Synced: 2025-04-08T08:06:00.416Z (3 months ago)
- Topics: es5-javascript, es6-javascript, javascript-es6-tutorial, oop
- Language: JavaScript
- Homepage:
- Size: 1.56 MB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# JavaScript
> Coding with `Bozlur Rosid Sagor`
In this topic I will use to visual stdio code(vs-code). First install `node.js` and `NPM`(node package manager) then install `vs-code` in your system. JavaScript `ES6` features is awesome if you learn the `ES6` you may easily handel `react, VUE, Angular` project.
```javascript
my_bio = () => "A simplest changes make huge difference.";
```##### Install Node on Mac.
First, install Homebrew.
``/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"``
Then you may follow the command
```
brew update
brew doctor
```
Next, add Homebrew’s location to your $PATH in your .bash_profile or .zshrc file.
```
export PATH="/usr/local/bin:$PATH"
brew install node
npm install -g grunt-cli
```
##### Check the node and NPM version both:
```
npm -v
node -v
```###### Features:
- ES6 basic
- Variable data type
- Map
- Filter
- Conditional Statement
- Special data type
- Fibonacci
- Factorial
- Recursion
- Stack
- Queue
- Link list
- Binary search- Loop
- For loop
- While loop
- Do while loop- Function
- Old function
- Arrow function
- Callback function
- Promise- OOP
- Class
- Constructor
- Object###### Intro of `filter` method
```javascript
arrayObject.filter(callback, contextObject);
```
The `filter()` method creates a new array with all the elements that pass the test implemented by the `callback()` function.
Internally, the `filter()` method iterates over each element of the array and pass each element to the `callback` function. If the `callback` function returns `true`, it includes the element in the return array.
The `filter()` method accepts two named arguments: a `callback` function and an optional object.###### Generator in javascript: Base64 converter
```javascript
// Helper function to convert file to Base64
const convertToBase64 = (file) => {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = () => resolve(reader.result);
reader.onerror = (error) => reject(error);
reader.readAsDataURL(file);
});
};
```####### Convert:
```javascript
const handleFileChange = async (event) => {
const file = event.target.files[0];
if (file) {
try {
const base64 = await convertToBase64(file);
setIcon(base64); // Save Base64 string
} catch (err) {
console.error("Error converting file to Base64:", err);
}
}
};
```