TheObject type represents one of JavaScript's data types. It is used to store various keyed collections and more complex entities. Objects can be created using the Object() constructor or the object initializer / literal syntax.
Nearly all objects in JavaScript are instances of Object; a typical object inherits properties (including methods) from Object.prototype, although these properties may be shadowed (a.k.a. overridden). The only objects that don't inherit from Object.prototype are those with null prototype, or descended from other null prototype objects.
You should avoid calling any Object.prototype method directly from the instance, especially those that are not intended to be polymorphic (i.e. only its initial behavior makes sense and no descending object could override it in a meaningful way). All objects descending from Object.prototype may define a custom own property that has the same name, but with entirely different semantics from what you expect. Furthermore, these properties are not inherited by null-prototype objects. All modern JavaScript utilities for working with objects are static. More specifically:
In case where a semantically equivalent static method doesn't exist, or if you really want to use the Object.prototype method, you should directly call() the Object.prototype method on your target object instead, to prevent the object from having an overriding property that produces unexpected results.
Almost all objects in JavaScript ultimately inherit from Object.prototype (see inheritance and the prototype chain). However, you may create null-prototype objects using Object.create(null) or the object initializer syntax with __proto__: null (note: the __proto__ key in object literals is different from the deprecated Object.prototype.__proto__ property). You can also change the prototype of an existing object to null by calling Object.setPrototypeOf(obj, null).
An object with a null prototype can behave in unexpected ways, because it doesn't inherit any object methods from Object.prototype. This is especially true when debugging, since common object-property converting/detecting utility functions may generate errors, or lose information (especially if using silent error-traps that ignore errors).
Making your object not inherit from Object.prototype also prevents prototype pollution attacks. If a malicious script adds a property to Object.prototype, it will be accessible on every object in your program, except objects that have null prototype.
Groups the elements of a given iterable according to the string values returned by a provided callback function. The returned object has separate properties for each group, containing arrays with the elements in the group.
The constructor function that created the instance object. For plain Object instances, the initial value is the Object constructor. Instances of other constructors each inherit the constructor property from their respective Constructor.prototype object.
When altering the behavior of existing Object.prototype methods, consider injecting code by wrapping your extension before or after the existing logic. For example, this (untested) code will pre-conditionally execute custom logic before the built-in logic or someone else's extension is executed.
When modifying prototypes with hooks, pass this and the arguments (the call state) to the current behavior by calling apply() on the function. This pattern can be used for any prototype, such as Node.prototype, Function.prototype, etc.
This calls the __anext__() method of async_iterator,returning an awaitable. Awaiting this returns the next value of theiterator. If default is given, it is returned if the iterator is exhausted,otherwise StopAsyncIteration is raised.
As repr(), return a string containing a printable representation of anobject, but escape the non-ASCII characters in the string returned byrepr() using \x, \u, or \U escapes. This generates a stringsimilar to that returned by repr() in Python 2.
Return True if the object argument appears callable,False if not. If this returns True, it is still possible that acall fails, but if it is False, calling object will never succeed.Note that classes are callable (calling a class returns a new instance);instances are callable if their class has a __call__() method.
A class method can be called either on the class (such as C.f()) or on an instance (suchas C().f()). The instance is ignored except for its class. If a classmethod is called for a derived class, the derived class object is passed as theimplied first argument.
Compile the source into a code or AST object. Code objects can be executedby exec() or eval(). source can either be a normal string, abyte string, or an AST object. Refer to the ast module documentationfor information on how to work with AST objects.
The mode argument specifies what kind of code must be compiled; it can be'exec' if source consists of a sequence of statements, 'eval' if itconsists of a single expression, or 'single' if it consists of a singleinteractive statement (in the latter case, expression statements thatevaluate to something other than None will be printed).
Compiler options and future statements are specified by bits which can bebitwise ORed together to specify multiple options. The bitfield required tospecify a given future feature can be found as thecompiler_flag attribute on the_Feature instance in the __future__ module.Compiler flags can be found in astmodule, with PyCF_ prefix.
When compiling a string with multi-line code in 'single' or'eval' mode, input must be terminated by at least one newlinecharacter. This is to facilitate detection of incomplete and completestatements in the code module.
If the argument is a string, it must contain either a real part (in thesame format as for float()) or an imaginary part (in the sameformat but with a 'j' or 'J' suffix), or both real and imaginaryparts (the sign of the imaginary part is mandatory in this case).The string can optionally be surrounded by whitespaces and the roundparentheses '(' and ')', which are ignored.The string must not contain whitespace between '+', '-', the'j' or 'J' suffix, and the decimal number.For example, complex('1+2j') is fine, but complex('1 + 2j') raisesValueError.More precisely, the input must conform to the complexvalueproduction rule in the following grammar, after parentheses and leading andtrailing whitespace characters are removed:
If two arguments are provided or keyword arguments are used, each argumentmay be any numeric type (including complex).If both arguments are real numbers, return a complex number with the realcomponent real and the imaginary component imag.If both arguments are complex numbers, return a complex number with the realcomponent real.real-imag.imag and the imaginary componentreal.imag+imag.real.If one of arguments is a real number, only its real component is used inthe above expressions.
3a8082e126