HomeCloud ComputingECMAScript 2025: The very best new options in JavaScript

ECMAScript 2025: The very best new options in JavaScript




perform fetchData(key) { 
  if (cache[key]) { 
    return cache[key]; 
  } else { 
    return new Promise(resolve => { 
      setTimeout(() => { knowledge = { id: key, identify: `New Merchandise ${key}`, supply: "DB" }; 
        cache[key] = knowledge; 
      }, 500);
    }); 
  } 
}

Whether or not that hits or not, Promise.attempt will settle for the decision and route all errors to the catch block:


Promise.attempt(() => fetchData("consumer:1")) 
  .then(knowledge => console.log("End result 1 (from cache):", knowledge))
  .catch(error => console.error("Error 1:", error.message));

Float16Array TypedArray

This replace is described within the spec as “added a brand new Float16Array TypedArray type in addition to the associated DataView.prototype.getFloat16, DataView.prototype.setFloat16, and Math.f16round strategies.”

The Float16 sort is utilized in high-performance computing, the place the appliance wants to maximise the reminiscence utilization by buying and selling footprint for precision. This contains machine studying, which might be the driving force for this addition.

JavaScript has not added a brand new scalar numeric sort. It nonetheless solely has Quantity, nevertheless it now has Float16Array for holding collections of this kind. JavaScript Quantity makes use of double precision 64-bit floating level format; nevertheless, in circumstances the place you might be utilizing giant quantities of numbers, the place much less precision is suitable (as in neural community weights and biases), utilizing 16-bit could be a massive optimization.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments