Dev Dastan
324 subscribers
49 photos
2 videos
41 links
πŸ”Έ Programming Tips and Concepts πŸ‘Ύ

πŸ”ΉContact: @Hossein13M 🀘🏻
Download Telegram
✨ Object.freeze vs Object.seal in JavaScript


❓ Object.seal prevents adding and/or removing properties from the sealed object and makes every existing property non-configurable.

❓ Object.freeze does Exactly what Object.seal do, plus It prevents modifying any existing properties.


❗️ There are Object.isFrozen() and Object.isSealed() methods to check if an object is frozen or sealed.


βž–βž–βž–βž–βž–βž–
πŸ“Έ Image Credit: [here]
πŸ“– Stack Overflow Answer: [here]
βž–βž–βž–βž–βž–βž–
#JavaScript #Programming


πŸ–₯ Follow @devDastan for more content.
Please open Telegram to view this post
VIEW IN TELEGRAM
πŸ‘15❀9😎3🍌1
✨ JavaScript's Garbage Collection

ℹ️ The garbage collector in JavaScript is responsible for reclaiming memory occupied by objects that are no longer needed. This mechanism is done using mark-and-sweep algorithm.

ℹ️ The mark-and-sweep algorithm consists of two main phases:

1️⃣Marking: Garbage collector marks reachable objects from the global object, ensuring none are left unmarked if reachable from a rooted object.

2️⃣ Sweeping: Garbage collector reclaims memory from unmarked objects, freeing it up for future use.


πŸ“• Learn more about the JS's garbage collector's mechanism and best practices on the Medium I have written.


βž–βž–βž–βž–βž–βž–
πŸ“šArticle (Written by me!): [here]
βž–βž–βž–βž–βž–βž–
#JavaScript #Algorithm


πŸ–₯ Follow @devDastan for more content.
Please open Telegram to view this post
VIEW IN TELEGRAM
πŸ‘8❀7🀯1
πŸ“± Abstract Syntax Trees (AST) in JavaScript


ℹ️ AST in JavaScript represents the syntactic structure of code. It's a hierarchical tree-like structure composed of nodes, each representing a syntactic element like variable declarations or function calls. An AST is created through two key stages:


1️⃣ Lexical Analysis (Tokenization): Code is tokenized by a Lexical Analyzer, breaking it down into tokens. Lexical Analysis: Code is tokenized by a Lexical Analyzer, breaking it down into tokens.

2️⃣ Syntax Analysis (Parsing): Tokens are structured into an AST by a Syntax Analyzer or Parser, enabling deeper code analysis.

βœ”οΈ AST use cases:

πŸ”£Code Analysis: ESLint, JSHint, TypeScript Compiler (TSC), SonarQube

πŸ”£Code Transformation: Babel, TypeScript Compiler (TSC), SWC

πŸ”£Refactoring: TSLint, TypeScript Compiler (TSC)

πŸ”£Code Generation: TypeScript Compiler (TSC), Babel

πŸ”£Language Tooling: Visual Studio Code, WebStorm, Atom, Sublime Text

πŸ”£Optimization: V8 JavaScript Engine, LLVM (Low-Level Virtual Machine)


βž–βž–βž–βž–βž–βž–
πŸ“š Article: [here]
πŸ’» AST Explorer Tool: [here]
βž–βž–βž–βž–βž–βž–
#JavaScript #computerScience


πŸ–₯ Follow @devDastan for more content.
Please open Telegram to view this post
VIEW IN TELEGRAM
πŸ‘13❀5
πŸ“± JavaScript Signals Standard Proposal (Stage 1)


πŸ•― Signals are a reactive state management mechanism for JavaScript apps. Each Signal is a source of a value. When the value changes, the Signal makes sure all dependent states (or other Signals) are notified and updated.

❗️ Frameworks like Angular, VueJS, SolidJS, and ... heavily utilize Signals. Establishing a standard for JavaScript itself would be beneficial (it is currently at stage 1).

βœ”οΈ Advantages of Signals:

πŸ”£ Simplified Reactive Programming

πŸ”£ Automated State Tracking and Updating

πŸ”£ Efficient Performance

πŸ”£ Cross-Framework Unity


πŸ”  A simple proposed signal example:

const counter = new Signal.State(0);

// Read the value of Signal
console.log(counter.get()); // Output: 0

// Change the value of Signal
counter.set(1);
console.log(counter.get()); // Output: 1


⚠️ If you have experience using ref in VueJS, understanding Signals should pose no challenge.

⚠️ The purpose of using Signals is to update only the dependencies in the DOM and execute subscriber functions in JavaScript.

βž–βž–βž–βž–βž–βž–
πŸ“± GitHub Proposal Repo: [here]
πŸ“š Article: [here]
πŸ“± YouTube Video: [here]
βž–βž–βž–βž–βž–βž–
#JavaScript #EcmaScript


πŸ–₯ Follow @devDastan for more content.
Please open Telegram to view this post
VIEW IN TELEGRAM
πŸ‘8❀4🀯2