Skip to content
  • Home
  • About
  • No Access
  • Privacy Policy
Bits of .NET
Bits of .NET
  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy

Category: JavaScript

JavaScript

JavaScript: Use Destructuring for Clean Assignment

- 18.07.26 - ErcanOPAK comment on JavaScript: Use Destructuring for Clean Assignment

πŸ“¦ Destructuring = Clean Assignment Extracting values is verbose. Destructuring makes it clean. Arrays, objects β€” assign with ease. ❌ Verbose Extraction const user = { name: ‘Alice’, age: 30 }; const name = user.name; const age = user.age; βœ… Destructuring const user = { name: ‘Alice’, age: 30 }; const { name, age } […]

Read More
JavaScript

JavaScript: Use Strict Mode for Better Code

- 15.07.26 - ErcanOPAK comment on JavaScript: Use Strict Mode for Better Code

⚑ Strict Mode = Better Code JavaScript is forgiving. Strict mode is strict. Catch errors early, write better code. πŸ“ Strict Mode Basics // Enable for entire script “use strict”; // Enable for function only function strictFunction() { “use strict”; // strict code } // Examples of strict mode // 1. Cannot use undeclared variables […]

Read More
JavaScript

JavaScript: Understand Closures for Scope and Privacy

- 15.07.26 - ErcanOPAK comment on JavaScript: Understand Closures for Scope and Privacy

πŸ”’ Closures = Scope + Privacy Variables leak globally? Closures create private scope. Data privacy, factory functions, state management. πŸ“ Closure Examples // Basic closure function outer() { let privateVar = ‘secret’; return function inner() { console.log(privateVar); // ‘secret’ }; } const closure = outer(); closure(); // Uses privateVar // Private counter function createCounter() { […]

Read More
JavaScript

JavaScript: Understand the Event Loop

- 15.07.26 - ErcanOPAK comment on JavaScript: Understand the Event Loop

πŸ”„ Event Loop = How JS Works JavaScript is single-threaded. Event Loop handles async operations. Understand how JS runs. πŸ“ Event Loop Concepts // Call Stack function first() { console.log(‘First’); } function second() { console.log(‘Second’); } first(); second(); // Output: First, Second // Web APIs (Browser) setTimeout(() => console.log(‘Timeout’), 0); console.log(‘End’); // Output: End, Timeout […]

Read More
JavaScript

JavaScript: Understand Hoisting

- 12.07.26 - ErcanOPAK comment on JavaScript: Understand Hoisting

πŸ“€ Hoisting = Declaration Lifting Variables behave strangely. Hoisting explains it. Declarations lifted, assignments stay. πŸ“ Hoisting Examples // var hoisting console.log(x); // undefined (not error) var x = 5; // Equivalent to: var x; console.log(x); // undefined x = 5; // function hoisting sayHello(); // “Hello” function sayHello() { console.log(‘Hello’); } // function expression […]

Read More
JavaScript

JavaScript: Master Promises for Async Operations

- 12.07.26 - ErcanOPAK comment on JavaScript: Master Promises for Async Operations

🀝 Promises = Async Operations Callback hell is ugly. Promises make async code elegant. Chain, catch, await β€” async made easy. ❌ Callback Hell getUser(function(user) { getOrders(user, function(orders) { getDetails(orders, function(details) { console.log(details); }); }); }); βœ… Promise Chain getUser() .then(user => getOrders(user)) .then(orders => getDetails(orders)) .then(details => console.log(details)) .catch(err => console.error(err)); πŸ“ Promise Methods […]

Read More
JavaScript

JavaScript: Use Template Literals for Clean Strings

- 12.07.26 - ErcanOPAK comment on JavaScript: Use Template Literals for Clean Strings

πŸ“ Template Literals = Clean Strings String concatenation is messy. Template literals are clean. Embed expressions, multiline strings. ❌ Concatenation const msg = ‘Hello ‘ + name + ‘, you are ‘ + age + ‘ years old.’; βœ… Template Literal const msg = `Hello ${name}, you are ${age} years old.`; πŸ“ Template Literal Examples […]

Read More
JavaScript

JavaScript: Use Nullish Coalescing (??) for Defaults

- 11.07.26 - ErcanOPAK comment on JavaScript: Use Nullish Coalescing (??) for Defaults

?? Nullish Coalescing = Clean Defaults || has problems. Nullish coalescing (??) is better. Only null/undefined triggers default. ❌ Logical OR (||) const count = 0; const result = count || 10; // result = 10 (but should be 0!) βœ… Nullish Coalescing (??) const count = 0; const result = count ?? 10; // […]

Read More
JavaScript

JavaScript: Master ES6 Classes for OOP

- 11.07.26 - ErcanOPAK comment on JavaScript: Master ES6 Classes for OOP

πŸ“¦ ES6 Classes = OOP in JavaScript Prototypes are confusing. ES6 Classes make OOP simple. Constructor, inheritance, methods. πŸ“ Class Basics // Class declaration class User { constructor(name, email) { this.name = name; this.email = email; this.createdAt = new Date(); } greet() { return `Hello, ${this.name}!`; } getEmail() { return this.email; } } // Usage […]

Read More
JavaScript

JavaScript: Use Optional Chaining for Safe Access

- 11.07.26 - ErcanOPAK comment on JavaScript: Use Optional Chaining for Safe Access

πŸ›‘οΈ Optional Chaining = Safe Access Null checks are verbose. Optional chaining is elegant. Safe property access, no errors. ❌ Verbose Null Checks if (user && user.address && user.address.city) { console.log(user.address.city); } βœ… Optional Chaining console.log(user?.address?.city); πŸ“ Optional Chaining Examples // Property access const city = user?.address?.city ?? ‘Unknown’; // Method calls const result = […]

Read More
JavaScript

JavaScript: Use Memoization for Performance

- 10.07.26 - ErcanOPAK comment on JavaScript: Use Memoization for Performance

⚑ Memoization = Performance Repeated calculations are slow. Memoization caches results. Speed up functions, improve performance. πŸ“ Memoization Basics // Simple memoization function memoize(fn) { const cache = {}; return function(…args) { const key = JSON.stringify(args); if (cache[key] === undefined) { cache[key] = fn(…args); } return cache[key]; }; } // Expensive function function slowFunction(n) { […]

Read More
JavaScript

JavaScript: Master Async/Await for Modern Async Code

- 10.07.26 - ErcanOPAK comment on JavaScript: Master Async/Await for Modern Async Code

⚑ Async/Await = Modern Async Promises are good. Async/Await is better. Write async code like sync code. Cleaner, more readable. ❌ Promise Chain fetchUser() .then(user => fetchOrders(user)) .then(orders => fetchDetails(orders)) .then(details => console.log(details)) .catch(err => console.error(err)); βœ… Async/Await try { const user = await fetchUser(); const orders = await fetchOrders(user); const details = await fetchDetails(orders); […]

Read More
JavaScript

JavaScript: Master the Spread Operator (…)

- 10.07.26 - ErcanOPAK comment on JavaScript: Master the Spread Operator (…)

… Spread Operator = Power Copying arrays is tedious. Spread operator makes it easy. Copy, merge, expand β€” clean code. πŸ“ Spread with Arrays // Copy array const original = [1, 2, 3]; const copy = […original]; console.log(copy); // [1, 2, 3] // Merge arrays const arr1 = [1, 2, 3]; const arr2 = [4, […]

Read More
JavaScript

JavaScript: Master the this Keyword

- 09.07.26 - ErcanOPAK comment on JavaScript: Master the this Keyword

🎯 Master the this Keyword this is confusing. Understanding this is essential. Context, binding, arrow functions β€” master it. πŸ“ this in Different Contexts // Global context console.log(this); // Window (browser) // Function context function showThis() { console.log(this); // Window (strict: undefined) } // Object method const obj = { name: ‘Alice’, greet: function() { […]

Read More
JavaScript

JavaScript: Use Proxy for Object Interception

- 09.07.26 - ErcanOPAK comment on JavaScript: Use Proxy for Object Interception

πŸ›‘οΈ Proxy = Object Interception Objects are exposed. Proxy intercepts operations. Validation, logging, reactivity, access control. πŸ“ Proxy Basics // Basic proxy const target = { name: ‘Alice’, age: 30 }; const handler = { get: function(obj, prop) { console.log(`Getting ${prop}`); return obj[prop]; }, set: function(obj, prop, value) { console.log(`Setting ${prop} to ${value}`); obj[prop] = […]

Read More
JavaScript

JavaScript: Use Generators for Iterable Functions

- 09.07.26 - ErcanOPAK comment on JavaScript: Use Generators for Iterable Functions

πŸ”„ Generators = Iterable Functions Normal functions run completely. Generators pause and resume. Infinite lists, async flows, custom iteration. πŸ“ Generator Basics // Generator function function* numberGenerator() { yield 1; yield 2; yield 3; } // Using generator const gen = numberGenerator(); console.log(gen.next()); // { value: 1, done: false } console.log(gen.next()); // { value: 2, […]

Read More
JavaScript

JavaScript: Use Web Workers for Multi-threading

- 07.07.26 - ErcanOPAK comment on JavaScript: Use Web Workers for Multi-threading

🧡 Web Workers = Multi-threading JavaScript is single-threaded. Web Workers enable multi-threading. Heavy tasks offloaded, UI remains responsive. πŸ“ Worker Basics // Main thread (app.js) const worker = new Worker(‘worker.js’); // Send message to worker worker.postMessage({ type: ‘calculate’, data: [1, 2, 3, 4, 5] }); // Receive message from worker worker.onmessage = function(event) { console.log(‘Result:’, […]

Read More
JavaScript

JavaScript: Use ES6 Modules for Organized Code

- 07.07.26 - ErcanOPAK comment on JavaScript: Use ES6 Modules for Organized Code

πŸ“¦ ES6 Modules = Organized Code Global namespace is messy. ES6 modules organize code. Import/export, encapsulation, dependency management. ❌ Script Tags (Messy) <script src=”utils.js”></script> <script src=”app.js”></script> // Global variables everywhere βœ… ES6 Modules (Clean) <script type=”module” src=”app.js”></script> // Import/export only what’s needed πŸ“ Module Examples // math.js (exports) export const add = (a, b) => […]

Read More
JavaScript

JavaScript: Understand Closures for Scope and Privacy

- 07.07.26 - ErcanOPAK comment on JavaScript: Understand Closures for Scope and Privacy

πŸ”’ Closures = Scope + Privacy Variables leak globally? Closures create private scope. Data privacy, factory functions, state management. πŸ“ Closure Examples // Basic closure function outer() { let privateVar = ‘secret’; return function inner() { console.log(privateVar); // ‘secret’ }; } const closure = outer(); closure(); // Uses privateVar // Private counter function createCounter() { […]

Read More
JavaScript

JavaScript: Use Event Delegation for Efficient Events

- 05.07.26 - ErcanOPAK comment on JavaScript: Use Event Delegation for Efficient Events

🎯 Event Delegation = Efficient Events Many event listeners = slow. Event delegation uses one listener on parent. Efficient, dynamic, clean. ❌ Many Listeners document.querySelectorAll(‘button’) .forEach(btn => { btn.addEventListener(‘click’, handleClick); }); βœ… Event Delegation document.querySelector(‘ul’) .addEventListener(‘click’, (e) => { if (e.target.matches(‘button’)) { handleClick(e); } }); πŸ“ Delegation Examples // List items document.querySelector(‘ul’).addEventListener(‘click’, (e) => { […]

Read More
JavaScript

JavaScript: Use Promises for Better Async Handling

- 05.07.26 - ErcanOPAK comment on JavaScript: Use Promises for Better Async Handling

🀝 Promises = Better Async Callback hell is ugly. Promises make async code elegant. Chain, catch, await β€” async made easy. ❌ Callback Hell getUser(function(user) { getOrders(user, function(orders) { getDetails(orders, function(details) { console.log(details); }); }); }); βœ… Promise Chain getUser() .then(user => getOrders(user)) .then(orders => getDetails(orders)) .then(details => console.log(details)) .catch(err => console.error(err)); πŸ“ Promise Methods […]

Read More
JavaScript

JavaScript: Use Local Storage for Client-Side Data

- 05.07.26 - ErcanOPAK comment on JavaScript: Use Local Storage for Client-Side Data

πŸ’Ύ Local Storage = Browser Database Need to store user data in browser? Local storage persists data across sessions. No server needed. πŸ“ Local Storage Methods // Set data localStorage.setItem(‘key’, ‘value’); // Get data const value = localStorage.getItem(‘key’); // Remove data localStorage.removeItem(‘key’); // Clear all data localStorage.clear(); // Get all keys const keys = Object.keys(localStorage); […]

Read More
JavaScript

JavaScript: Use Fetch API for Modern HTTP Requests

- 04.07.26 - ErcanOPAK comment on JavaScript: Use Fetch API for Modern HTTP Requests

🌐 Fetch = Modern HTTP Requests XMLHttpRequest is old. Fetch API is modern, promise-based. Cleaner, simpler, more powerful. ❌ XMLHttpRequest const xhr = new XMLHttpRequest(); xhr.open(‘GET’, ‘/api/users’); xhr.onload = function() { if (xhr.status === 200) { const data = JSON.parse(xhr.responseText); console.log(data); } }; xhr.send(); βœ… Fetch API fetch(‘/api/users’) .then(response => response.json()) .then(data => console.log(data)) .catch(error […]

Read More
JavaScript

JavaScript: Use Map and Set for Efficient Data Structures

- 04.07.26 - ErcanOPAK comment on JavaScript: Use Map and Set for Efficient Data Structures

πŸ“¦ Map = Key-Value. Set = Unique Values. Objects are key-value, but limited. Map is better for key-value. Set stores unique values. Faster, cleaner. πŸ“˜ Object const obj = {}; obj.name = “Alice”; obj.age = 30; // Keys are strings only πŸ“— Map const map = new Map(); map.set(‘name’, ‘Alice’); map.set(42, ‘Answer’); map.set(true, ‘Boolean key’); […]

Read More
JavaScript

JavaScript: Use Arrow Functions for Cleaner Code

- 04.07.26 - ErcanOPAK comment on JavaScript: Use Arrow Functions for Cleaner Code

➑️ Arrow Functions = Concise Functions function() { } is verbose. Arrow functions are concise. Lexical this binding, implicit returns. Essential for modern JavaScript. ❌ Regular Function const add = function(a, b) { return a + b; }; const double = function(x) { return x * 2; }; βœ… Arrow Function const add = (a, […]

Read More
JavaScript

JavaScript: Use setTimeout and setInterval for Timers

- 24.06.26 - ErcanOPAK comment on JavaScript: Use setTimeout and setInterval for Timers

⏰ Timers = Delayed or Repeated Execution Need to delay execution? Run repeatedly? setTimeout and setInterval handle timing. Animations, polling, delays. πŸ“ setTimeout (Delay) // Execute after 2 seconds setTimeout(() => { console.log(‘2 seconds passed’); }, 2000); // With parameters setTimeout((name) => { console.log(`Hello ${name}`); }, 1000, ‘Alice’); // Clear timeout const timer = setTimeout(() […]

Read More
JavaScript

JavaScript: Understand Hoisting to Avoid Surprises

- 24.06.26 - ErcanOPAK comment on JavaScript: Understand Hoisting to Avoid Surprises

πŸ“ˆ Hoisting = Declarations Move to Top JavaScript hoists declarations. Understand hoisting to avoid bugs. var, let, const, function declarations β€” different hoisting behavior. πŸ“ var Hoisting console.log(x); // undefined (not error) var x = 5; // Equivalent to: var x; console.log(x); // undefined x = 5; // Function declaration hoisting sayHello(); // Works! function […]

Read More
JavaScript

JavaScript: Master Array Methods for Data Manipulation

- 24.06.26 - ErcanOPAK comment on JavaScript: Master Array Methods for Data Manipulation

πŸ“Š Arrays Are Everywhere Lists of data need manipulation. Array methods filter, map, reduce, sort. Essential for data processing. πŸ“ Common Array Methods // forEach: Iterate const numbers = [1, 2, 3, 4, 5]; numbers.forEach(n => console.log(n)); // map: Transform each element const doubled = numbers.map(n => n * 2); // [2, 4, 6, 8, […]

Read More
JavaScript

JavaScript: Understand the Event Loop for Async Programming

- 21.06.26 - ErcanOPAK comment on JavaScript: Understand the Event Loop for Async Programming

πŸ”„ Event Loop = How JavaScript Runs Async JavaScript is single-threaded. Event Loop handles async operations. Understanding it explains setTimeout, callbacks, promises. πŸ“ How Event Loop Works // 1. Call Stack (synchronous code) console.log(‘1’); // Stack // 2. Web APIs (async operations) setTimeout(() => { console.log(‘2’); // Callback queue }, 1000); // 3. Callback Queue […]

Read More
JavaScript

JavaScript: Use Strict Mode for Safer Code

- 21.06.26 - ErcanOPAK comment on JavaScript: Use Strict Mode for Safer Code

πŸ”’ Strict Mode = Fewer Bugs JavaScript has quirks. Strict mode prevents common mistakes. Safer code, fewer bugs, better performance. πŸ“ Enabling Strict Mode // Global strict mode ‘use strict’; // Function-level strict mode function myFunction() { ‘use strict’; // Strict code here } // In modules (strict by default) export default function() { // […]

Read More
Page 5 of 11
Β« Previous 1 2 3 4 5 6 7 8 9 10 11 Next Β»

Posts pagination

« Previous 1 … 3 4 5 6 7 … 11 Next »
November 2026
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
30  
« Oct    

Most Viewed Posts

  • How to make theater mode the default for Youtube (1,068)
  • Get the User Name and Domain Name from an Email Address in SQL (990)
  • How to add default value for Entity Framework migrations for DateTime and Bool (986)
  • Get the First and Last Word from a String or Sentence in SQL (865)
  • How to select distinct rows in a datatable in C# (859)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (661)
  • Add Constraint to SQL Table to ensure email contains @ (619)
  • Average of all values in a column that are not zero in SQL (577)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (553)
  • Find numbers with more than two decimal places in SQL (481)

Recent Posts

  • Network Speed Monitor Windows Application v2.5.1
  • Ağ HΔ±zΔ± Δ°zleyici Windows UygulamasΔ± v2.5.1
  • How to make theater mode the default for Youtube
  • The AI Prompt That Audits a Function for Thread-Safety Gaps
  • Ajax: Fix a Fetch Request Caching a Response Despite No-Store
  • WordPress: Fix a Navigation Block Losing Submenu Items After Sync
  • Visual Studio: Fix CodeLens Reference Counts Stuck at Stale Numbers
  • C#: Fix a UTF-8 String Literal Behaving Differently in a Switch
  • Photoshop: Fix a Liquify Mesh Snapping Back on a Smart Object
  • The AI Prompt That Turns a Crash Dump Into a Short Repro Script

Most Viewed Posts

  • How to make theater mode the default for Youtube (1,068)
  • Get the User Name and Domain Name from an Email Address in SQL (990)
  • How to add default value for Entity Framework migrations for DateTime and Bool (986)
  • Get the First and Last Word from a String or Sentence in SQL (865)
  • How to select distinct rows in a datatable in C# (859)

Recent Posts

  • Network Speed Monitor Windows Application v2.5.1
  • Ağ HΔ±zΔ± Δ°zleyici Windows UygulamasΔ± v2.5.1
  • How to make theater mode the default for Youtube
  • The AI Prompt That Audits a Function for Thread-Safety Gaps
  • Ajax: Fix a Fetch Request Caching a Response Despite No-Store

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com