What is the output?
  Anonymous Quiz
    25%
    Alice, undefined, Not found
      
    34%
    Value: Alice, Value: undefined, Not found
      
    30%
    Value: Alice, Not found, Not found
      
    11%
    Value: Value: Alice, Not found, Not found
      
    π4π€4
  Please open Telegram to view this post
    VIEW IN TELEGRAM
  π€£34π€5π4
  CHALLENGE
const weakSet = new WeakSet();
let obj1 = { id: 1 };
let obj2 = { id: 2 };
let obj3 = obj1;
weakSet.add(obj1);
weakSet.add(obj2);
const results = [
weakSet.has(obj1),
weakSet.has(obj3),
weakSet.has({ id: 2 }),
weakSet.has(obj2)
];
obj1 = null;
console.log(results);
β€3π1π€©1
  What is the output?
  Anonymous Quiz
    38%
    [true, true, false, true]
      
    33%
    [true, false, false, true]
      
    21%
    [false, true, false, true]
      
    9%
    [true, true, true, false]
      
    β€11π3π₯2π€1
  Please open Telegram to view this post
    VIEW IN TELEGRAM
  π€£7π6β€3π₯1π€©1
  CHALLENGE
console.log(1);
setTimeout(() => {
console.log(2);
Promise.resolve().then(() => console.log(3));
}, 0);
Promise.resolve()
.then(() => {
console.log(4);
setTimeout(() => console.log(5), 0);
})
.then(() => console.log(6));
console.log(7);
1π2β€1π€©1
  What is the output?
  Anonymous Quiz
    22%
    1, 7, 4, 6, 2, 5, 3
      
    33%
    1, 7, 4, 2, 6, 3, 5
      
    35%
    1, 7, 4, 6, 2, 3, 5
      
    10%
    1, 4, 7, 6, 2, 3, 5
      
    π6β€3π₯1
  CHALLENGE
const user = { name: 'Alice' };
const ratings = new WeakMap();
ratings.set(user, 5);
const result = [];
result.push(ratings.has(user));
result.push(ratings.get(user));
// Create a reference-free object
let tempUser = { name: 'Bob' };
ratings.set(tempUser, 10);
result.push(ratings.has(tempUser));
// Remove the reference
tempUser = null;
// Try to iterate through WeakMap
result.push(typeof ratings[Symbol.iterator]);
console.log(result);π₯5β€1
  What is the output?
  Anonymous Quiz
    28%
    [true, 5, true, 'undefined']
      
    33%
    [true, 5, false, 'undefined']
      
    25%
    [true, 5, true, 'function']
      
    14%
    [true, 5, true, undefined]
      
    π₯5β€1π1π€©1
  CHALLENGE
function processTransaction(amount) {
  try {
    if (typeof amount !== 'number') {
      throw new TypeError('Amount must be a number');
    }
    if (amount <= 0) {
      throw new RangeError('Amount must be positive');
    }
    return 'Transaction processed';
  } catch (error) {
    if (error instanceof TypeError) {
      return { status: 'Type Error', message: error.message };
    } else if (error instanceof RangeError) {
      return { status: 'Range Error', message: error.message };
    }
    return { status: 'Unknown Error', message: error.message };
  }
}
console.log(processTransaction(-50));π4π€©1
  What is the output?
  Anonymous Quiz
    21%
    Transaction processed
      
    35%
    RangeError: Amount must be positive
      
    23%
    { status: 'Type Error', message: 'Amount must be a number' }
      
    21%
    { status: 'Range Error', message: 'Amount must be positive' }
      
    π10β€2π₯1π€©1
  CHALLENGE
function modify(obj) {
  obj.a.push(4);
  obj.b = 'changed';
  return obj;
}
const original = { a: [1, 2, 3], b: 'original', c: { deep: true } };
const copy1 = { ...original };
const copy2 = JSON.parse(JSON.stringify(original));
modify(copy1);
console.log(original.a, original.b, copy2.c === original.c);π5β€1π€©1
  What is the output?
  Anonymous Quiz
    26%
    [1, 2, 3] 'original' true
      
    29%
    [1, 2, 3] 'original' false
      
    24%
    [1, 2, 3, 4] 'original' false
      
    21%
    [1, 2, 3, 4] 'changed' false
      
    π9β€2π₯1
  CHALLENGE
const result = (function() {
  let count = 0;
  
  return {
    increment() {
      return ++count;
    },
    get value() {
      return count;
    },
    reset() {
      const oldCount = count;
      count = 0;
      return oldCount;
    }
  };
})();
result.increment();
result.increment();
console.log(result.reset() + result.value + result.increment());π1
  π€6β€3π2π₯2
  The author notes generator functions have been widely available in JavaScript for a long time, yet βtheir practicality hasnβt exactly caught on.β This is a great look at what they are and where they can be useful.
Alex MacArthur
Please open Telegram to view this post
    VIEW IN TELEGRAM
  β€5π€£2π₯1
  Media is too big
    VIEW IN TELEGRAM
  Please open Telegram to view this post
    VIEW IN TELEGRAM
  π13π€£7β€3π₯1π€©1
  We need 40 boosts
https://t.me/javascript?boost
Please open Telegram to view this post
    VIEW IN TELEGRAM
  1π9β€3π₯2π€2
  CHALLENGE
  try {
  const arr = [1, 2, 3];
  
  function processArray() {
    try {
      nonExistentFunction();
    } catch (err) {
      throw new TypeError('Invalid type');
    }
  }
  
  try {
    processArray();
  } catch (err) {
    console.log(err instanceof Error, err instanceof TypeError, err.message);
  }
} catch (finalError) {
  console.log('Caught in outer block:', finalError);
}What is the output?
  Anonymous Quiz
    29%
    true true Invalid type
      
    38%
    true false 'nonExistentFunction is not defined'
      
    20%
    true true 'Invalid type'
      
    13%
    false true 'Invalid type'
      
    β€4π2π₯1
  A library to use the power of ANSI escape sequences for coloring and styling text in many environments including the terminal, Chromium-based browsers, Node, Bun, Deno, and even Next.js. v4.0 is a big upgrade with enough breaking changes to warrant a migration guide for existing users.
webdiscus
Please open Telegram to view this post
    VIEW IN TELEGRAM
  π6β€1π₯1