concept operation in category javascript

This is an excerpt from Manning's book The Joy of JavaScript.
Let’s explain this process in more detail. When requesting a member field, the JavaScript engine first looks for the property directly on the calling object. If it can’t find it there, it looks in [[Prototype]] and to see if it contains the requested property. The property sender is not declared in the moneyTransaction object, yet it’s still successfully resolves. Why is that? Any property access or method invocation happening in moneyTransaction will travel up the prototype chain, continuing to transaction, until it finds the property there and returns it. But what if it doesn’t? The look up process would continue and finally terminate at the empty object literal {} (aka Object.prototype). If resolution fails, the result of the operation is undefined.
Figure 5.6 Detailed execution of the composition of functions mapped over a Validation type. When the operations are successful, the container allows each operation to map over the wrapped data; otherwise, it simply skips to offer a recovery alternative
![]()
Symbol.species is a nice, clever artifact used to control what the constructor should be on a resultant or derived object after using operations on some original object. This is pretty vague to understand, so let’s look at 2 use cases for this symbol:
Promise.allSettled([ proofOfWorkAsync(block), rejectAfter(2) //#A ]) .then(results => { results.length // 2 results[0].status // 'fulfilled' //#B results[1].status // 'rejected' //#C results[0].value.index // 1 //#B results[1].reason.message // 'Operation rejected after 2 seconds' //#C })

This is an excerpt from Manning's book Deep Learning with JavaScript: Neural networks in TensorFlow.js.
At its core, TensorFlow was designed to be very general and flexible: the operations can be any well-defined mathematical functions, not just layers of neural networks. For example, they can be low-level mathematical operations such as adding and multiplying two tensors—the kind of operations that happen inside a neural network layer. This gives deep-learning engineers and researchers great power to define arbitrary and novel operations for deep learning. However, for a large fraction of deep-learning practitioners, manipulating such low-level machinery is more trouble than it’s worth. It leads to bloated and more error-prone code and longer development cycles. Most deep-learning engineers use a handful of fixed layer types (for instance, convolution, pooling, or dense, as you will learn in detail in later chapters). Rarely do they need to create new layer types. This is where the LEGO analogy is appropriate. With LEGOs, there are only a small number of block types. LEGO builders don’t need to think about what it takes to make a LEGO block. This is different from a toy like, say, Play-Doh, which is analogous to TensorFlow’s low-level API. Yet the ability to connect LEGO blocks leads to a combinatorially large number of possibilities and virtually infinite power. It is possible to build a toy house with either LEGOs or Play-Doh, but unless you have very special requirements for the house’s size, shape, texture, or material, it is much easier and faster to build it with LEGOs. For most of us, the LEGO house we build will stand more stably and look nicer than the Play-Doh house we’d make.
Figure 9.1. The internal architecture of a dense layer. The multiplication and addition performed by a dense layer is symmetric with respect to its inputs. Contrast this with a simpleRNN layer (figure 9.2), which breaks the symmetry by introducing step-by-step computation. Note that we assume the input has only four elements and omit the bias terms for simplicity. Also, we show the operations for only one output unit of the dense layer. The remaining units are represented as the stack of obscured boxes in the background.
![]()
To get the data back out of the tensor, we can use the async method data(). The method is async because, in general, the tensor may be hosted out of the main memory, such as on GPUs, as a WebGL texture. Retrieving the value of such tensors involves operations that are not guaranteed to resolve immediately, and we don’t want those operations to block the main JavaScript thread. This is why the data() method is async. There is also a synchronous function that retrieves the values of tensors through polling: dataSync(). This method is convenient but blocks the main JavaScript thread, so it should be used sparingly (for example, during debugging). Prefer the async data() method whenever possible: