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