13 Matching Annotations
  1. Sep 2023
    1. An object in object-oriented language is essentially a record that contains procedures specialized to handle that record; and object types are an elaboration of record types. Indeed, in most object-oriented languages, records are just special cases of objects, and are known as plain old data structures (PODSs), to contrast with objects that use OO features.
  2. Mar 2021
    1. function isObject(o) { return o instanceof Object && o.constructor === Object; }
    2. An array is from a logical point of view not an object - although JavaScript handles and reports them as such. In practice however, it is not helpful to see them equal, because they are not.
    3. Arrays are definitely objects. Not sure why you think objects can't have a length property nor methods like push, Object.create(Array.prototype) is a trivial counterexample of a non-array object which has these. What makes arrays special is that they are exotic objects with a custom [[DefineOwnProperty]] essential internal method, but they are still objects.
    4. arrays are not objects from a logical point of view. I'm speaking about program logic. It is sometimes necessary to check if an array is a "real" array and definitely not an "real" object. That's what Array.isArray() is for. Imagine you have a function which accepts an object or an array of objects.
    5. function isObject (item) { return (typeof item === "object" && !Array.isArray(item) && item !== null); }
  3. Oct 2020
    1. You can set options.params to a POJO as shown above, or to an instance of the JavaScript's built-in URLSearchParams class. const params = new URLSearchParams([['answer', 42]]); const res = await axios.get('https://httpbin.org/get', { params });
    1. Checking if an object is a POJO can be somewhat tricky and depends on whether you consider objects created using Object.create(null) to be POJOs. The safest way is using the Object.getPrototypeOf() function and comparing the object's prototype.
    2. The intuition behind POJOs is that a POJO is an object that only contains data, as opposed to methods or internal state. Most JavaScript codebases consider objects created using curly braces {} to be POJOs. However, more strict codebases sometimes create POJOs by calling Object.create(null) to avoid inheriting from the built-in Object class.