Search completed in 1.30 seconds.
Object.getOwnPropertyNames() - JavaScript
The ordering of the enumerable properties in the array is consistent with the ordering exposed by a for...in loop (or by Object.keys()) over the properties of the object. ...
...The ordering of the enumerable properties in the array is consistent with the ordering exposed by a for...in loop (or by Object.keys()) over the properties of the object. ...
... of all properties (including non-enumerable properties except for those which use Symbol) found directly in a given object. Syntax Object.getOwn
PropertyNames(obj) Parameters obj The object whose enumerable and non-enumerable properties are to be returned. Return value An array of strings that corresponds to the properties found directly in the given object. Description Object.getOwn
PropertyNames() returns an array whose elements are strings corresponding to the enumerable and non-enumerable properties found directly in a given object obj. The ordering of the enumerable properties in the array is consistent with the ordering exposed by a for...in loop (or by Object.keys()) over the properties of the object. The ordering of the non-enumerable properties in the array and the ordering among...
...And 8 more matches
nsIDBFolderInfo
a.org/????????????????????????????"] .createInstance(Components.interfaces.nsIDBFolderInfo); Method overview long AndFlags(in long flags); void ChangeExpungedBytes(in long delta); void ChangeNumMessages(in long delta); void ChangeNumUnreadMessages(in long delta); boolean getBooleanProperty(in string
propertyName, in boolean defaultValue); void getCharacterSet(out ACString charSet, out boolean overriden); void getCharacterSetOverride(out boolean characterSetOverride); Obsolete since Gecko 1.8 string getCharPtrCharacterSet(); string getCharPtrProperty(in string
propertyName); void getLocale(in nsString result); Native code only...
...terSetOverride); Obsolete since Gecko 1.8 string getCharPtrCharacterSet(); string getCharPtrProperty(in string
propertyName); void getLocale(in nsString result); Native code only! Obsolete since Gecko 1.8 void getMailboxName(in nsString boxName); Native code only! ...
...Property(in string
propertyName); void getLocale(in nsString result); Native code only! Obsolete since Gecko 1.8 void getMailboxName(in nsString boxName); Native code only! ...
...And 13 more matches
nsIMsgDBHdr
s marking it as read, or replied to, or whatever, you MUST do it through its corresponding nsIMsgFolder (msgHdr.folder) or nsIMsgDatabase (msgHdr.folder.msgDatabase). It is also mandatory to set msgHdr.folder.msgDatabase = null after performing this kind of operations to prevent leaking. Don't even think about using OrFlags and/or AndFlags. ...
...ou MUST do it through its corresponding nsIMsgFolder (msgHdr.folder) or nsIMsgDatabase (msgHdr.folder.msgDatabase). It is also mandatory to set msgHdr.folder.msgDatabase = null after performing this kind of operations to prevent leaking. Don't even think about using OrFlags and/or AndFlags. ...
...abase (msgHdr.folder.msgDatabase). It is also mandatory to set msgHdr.folder.msgDatabase = null after performing this kind of operations to prevent leaking. Don't even think about using OrFlags and/or AndFlags. ...
...And 10 more matches
Enumerability and ownership of properties - JavaScript
able Enumerable and Nonenumerable Not available without extra code Not available without extra code in Not available without extra code Retrieval Enumerable Nonenumerable Enumerable and Nonenumerable Object.keys getOwn
PropertyNames getOwnPropertySymbols getOwn
PropertyNames, getOwnPropertySymbols - filtered to exclude enumerables using propertyIsEnumerable getOwn
PropertyNames getOwnPropertySymbols Not available without extra code Not available without extra code Iterable Enumerable Nonenumerable...
...exclude enumerables using propertyIsEnumerable getOwn
PropertyNames getOwnPropertySymbols Not available without extra code Not available without extra code Iterable Enumerable Nonenumerable Enumerable and Nonenumerable Object.keys getOwn
PropertyNames getOwnPropertySymbols getOwn
PropertyNames, getOwnPropertySymbols - filtered to exclude enumerables using propertyIsEnumerable getOwn
PropertyNames getOwnPropertySymbols Enumerable Nonenumerable Enumerable and Nonenumerable for..in ...
...cient algorithm for all cases, but useful for a quick demonstration. ...
...And 5 more matches
nsIBoxObject
layout/xul/base/public/nsIBoxObject.idlScriptable Please add a summary to this article. Inherits from: nsISupports Last changed in Gecko 1.9 (Firefox 3) To get an instance, use the boxObject property. Where possible, element.getClientRects and element.getBoundingClientRect should be used instead. Method overview wstring getLookAndFeelMetric(in wstring
propertyName); Obsolete since Gecko 1.9 wstring getProperty(in wstring
propertyName); nsISupports getPropertyAsSupports(in wstring
propertyName); void removeProperty(in wstring
propertyName); void setProperty(in wstring
propertyName, in wstring propertyValue); void setPropertyAsSupports(in wstring
propertyName, in nsISupports value); Attributes Attribute Type Description element nsIDOMElement Read only. firstChild ns...
...of the box relative to the screen origin, in device pixels. Read only. width long The width of the box, in CSS pixels. Read only. x long The x coordinate of the box, in CSS pixels. Read only. y long The y coordinate of the box, in CSS pixels. Read only. ...
...reen origin, in device pixels. Read only. width long The width of the box, in CSS pixels. Read only. x long The x coordinate of the box, in CSS pixels. Read only. y long The y coordinate of the box, in CSS pixels. Read only. ...
...And 4 more matches
Old Proxy API - Archive of obsolete content
ld return a valid property descriptor object, or undefined to indicate that no property with name exists in the emulated object. Object.getPropertyDescriptor(proxy, name) getPropertyDescriptor: function(name) -> PropertyDescriptor | undefined This function doesn't exist in ECMAScript 5. Like getOwnPropertyDescriptor, but should also search the prototype chain. Object.getOwn
PropertyNames(proxy) getOwn
PropertyNames: function() -> Strings Array Return an array of all own (non-inherited) property names of the emulated object. Object.get
PropertyNames(proxy) get
PropertyNames: function() -> Strings Array This function doesn't exist in ECMAScript 5. Like getOwn
PropertyNames, but should also return non-overridden inherited properties. Object.defineProperty(...
... return true; } else { return false; } } } this.defineProperty(name, { value: val, writable: true, enumerable: true, configurable: true}); return true; } receiver is either the proxy or an object that inherits from the proxy. ...
...Array function() { return this.get
PropertyNames().filter( function (name) { return this.getPropertyDescriptor(name).enumerable } ); } From the proxy user point of view, properties appear in the for..in loop in the same order as they are in the returned array. Object.keys(proxy) keys: function() -> String Array function() { return this.getOwn
PropertyNames().filter( function (name) { return this.getOwnPropertyDescriptor(name).enumerable } ); } Invariants Even though proxies provide a lot of power to users, some operations are not trapped in order to keep the language consistent: The triple equal (===) operator is not trapped. p1 === p2 if and only if p1 and p2 refer to the same proxy. Fixing a proxy does not alt...
...And 2 more matches
nsIMimeConverter
written in the given charset. This should only be used by native code, as xpconnect translation causes it to not work properly. string encodeMimePartIIStr(in string header, in boolean structured, in string mailCharset, in long fieldnamelen, in long encodedWordSize); Parameters
propertyName The name of the property to retrieve. Return Value The value of the property. encodeMimePartIIStr_UTF8() Encodes a string into a MIME-encoded form according to RFC 2047. string encodeMimePartIIStr_UTF8(in AUTF8String header, in boolean structured, in string mailCharset, in long f...
...e MIME-encoded form. structured Whether or not this string may contain <> blocks which should not be encoded (e.g., the From and To headers). mailCharset The charset to encode into. fieldnamelen The length of the header field including the colon and space (": "). encodedWordSize The maximum line length of the encoded string. decodeMimeHeaderToCharPtr() void setStringProperty(in string
propertyName, in string propertyValue); Parameters
propertyName The name of the property to set. propertyValue The value of the property. decodeMimeHeader() string getStringProperty(in string
propertyName); Parameters
propertyName The name of the property to retrieve. Return Value The value of the property. B64EncoderInit() Get an integer property. Usually you wo...
...name of the property to set. propertyValue The value of the property. decodeMimeHeader() string getStringProperty(in string
propertyName); Parameters
propertyName The name of the property to retrieve. Return Value The value of the property. B64EncoderInit() Get an integer property. Usually you would use this to store you own properties. unsigned long getUint32Property(in string
propertyName); Parameters
propertyName The name of the property to retrieve. Thunderbird stored Uint32 properties (not a complete list): indexed Used for Spotlight integration on OSX. ...
...And 2 more matches
Working with objects - JavaScript
vaScript object has properties associated with it. A property of an object can be explained as a variable that is attached to the object. Object properties are basically the same as ordinary JavaScript variables, except for the attachment to objects. The properties of an object define the characteristics of the object. You access the properties of an object with a simple dot-notation: objectName.
propertyName Like all JavaScript variables, both the object name (which could be a normal variable) and property name are case sensitive. You can define a property by assigning it a value. For example, let's create an object named myCar and give it properties named make, model, and year as follows: var myCar = new Object(); myCar.make = 'Ford'; myCar.model = 'Mustang'; myCar.year = 1969; The above exampl...
...trings or Symbols (at some point, private names will also be added as the class fields proposal progresses, but you won't use them with [] form). For example, in the above code, when the key obj is added to the myObj, JavaScript will call the obj.toString() method, and use this result string as the new key. You can also access properties by using a string value that is stored in a variable: var
propertyName = 'make'; myCar[
propertyName] = 'Ford';
propertyName = 'model'; myCar[
propertyName] = 'Mustang'; You can use the bracket notation with for...in to iterate over all the enumerable properties of an object. To illustrate how this works, the following function displays the properties of the object when you pass the object and the object's name as arguments to the function: function showProps(obj,...
... Enumerate the properties of an object Starting with ECMAScript 5, there are three native ways to list/traverse object properties: for...in loops This method traverses all enumerable properties of an object and its prototype chain. Object.keys(o) This method returns an array with all the own (not in the prototype chain) enumerable properties' names ("keys") of an object o. Object.getOwn
PropertyNames(o) This method returns an array containing all own properties' names (enumerable or not) of an object o. Before ECMAScript 5, there was no native way to list all properties of an object. However, this can be achieved with the following function: function listAllProperties(o) { var objectToInspect; var result = []; for(objectToInspect = o; objectToInspect !== null; objectToIn...
...And 2 more matches
inIDOMUtils
); void clearPseudoClassLocks(in nsIDOMElement aElement); [implicit_jscontext] jsval colorNameToRGB(in DOMString aColorName); nsIArray getBindingURLs(in nsIDOMElement aElement); nsIDOMNodeList getChildrenForNode(in nsIDOMNode aNode, in boolean aShowingAnonymousContent); unsigned long long getContentState(in nsIDOMElement aElement); void getCSS
PropertyNames([optional] in unsigned long aFlags, [optional] out unsigned long aCount, [retval, array, size_is(aCount)] out wstring aProps); nsISupportsArray getCSSStyleRules(in nsIDOMElement aElement, [optional] in DOMString aPseudo); nsIDOMNode getParentForNode(in nsIDOMNode aNode, in boolean aShowingAnonymousContent); unsigned long getRuleLine(in nsIDOMCSSStyleRule aRule); ...
...SelectorIndex); unsigned long long getSpecificity(in nsIDOMCSSStyleRule aRule, in unsigned long aSelectorIndex); nsIDOMFontFaceList getUsedFontFaces(in nsIDOMRange aRange); bool hasPseudoClassLock(in nsIDOMElement aElement, in DOMString aPseudoClass); boolean isIgnorableWhitespace(in nsIDOMCharacterData aDataNode); bool isInheritedProperty(in AString a
PropertyName); void parseStyleSheet(in nsIDOMCSSStyleSheet aSheet, in DOMString aInput); void removePseudoClassLock(in nsIDOMElement aElement, in DOMString aPseudoClass); AString rgbToColorName(in octet aR, in octet aG, in octet aB); bool selectorMatchesElement(in nsIDOMElement aElement, in nsIDOMCSSStyleRule aRule, in unsigned long aSelectorIndex, [optional] in DOMString ...
... a result of the insertion point. getContentState() A bit mask of the supported content state flags, which are listed in Content state flags. unsigned long long getContentState( in nsIDOMElement aElement ); Parameters aElement A DOM Element to retrieve the content states of. Return value A bitmask of one of the 6 supported content state flags specified in Content state flags. getCSS
PropertyNames() Get a list of all our supported property names void getCSS
PropertyNames( in unsigned long aFlags, Optional out unsigned long aCount, Optional [retval, array, size_is(aCount)] out wstring aProps ); Parameters aFlags Optional Shorthands can be excluded or property aliases included. See constants. aCount Optional Count aProps Properties getCSSStyleRules() Returns an array of ...
...a aDataNode ); Parameters aDataNode A DOM CharacterData node; that is, a text node. Return value true if the node only contains insignificant whitespace. In particular, this will be false if certain CSS white-space styles are in effect. isInheritedProperty() Determines if the specified string names a CSS property that is inherited by default. boolean isInheritedProperty( in AString a
PropertyName ); Parameters a
PropertyName The name of the CSS property. Return value true if the property is inherited, otherwise false. parseStyleSheet() Parse CSS and update the style sheet in place. void parseStyleSheet( in nsIDOMCSSStyleSheet aSheet, in DOMString aInput ); Parameters aSheet A DOMCSSStyleSheet. aInput A DOMString. The new source string for the style sheet. Return v...
nsIAccessNode
ily. The nsIAccessNode tree for a given DOM window has a one to one relationship to the DOM tree. If the DOM node for this access node is "accessible", then a QueryInterface to nsIAccessible will succeed. ...
...ee. If the DOM node for this access node is "accessible", then a QueryInterface to nsIAccessible will succeed. Method overview nsIAccessNode getChildNodeAt(in long childNum); Obsolete since Gecko 2.0 nsIDOMCSSPrimitiveValue getComputedStyleCSSValue(in DOMString pseudoElt, in DOMString
propertyName); DOMString getComputedStyleValue(in DOMString pseudoElt, in DOMString
propertyName); void scrollTo(in unsigned long aScrollType); void scrollToPoint(in unsigned long aCoordinateType, in long aX, in long aY); Attributes Note: Attempting to access the attributes of a node that is unattached from the accessible tree will result in an exception - NS_ERROR_FAILURE. Attribute Type Description document nsIAccessibleDocument Th...
...e() Retrieve the computed style value as nsIDOMCSSPrimitiveValue for the DOM node this access node is associated with. Note: The meanings of width, height and other size measurements depend on the version of CSS being used. Therefore, for bounds information, it is better to use nsIAccessible.getBounds(). nsIDOMCSSPrimitiveValue getComputedStyleCSSValue( in DOMString pseudoElt, in DOMString
propertyName ); Parameters pseudoElt The pseudo element to retrieve style for, or empty string for general computed style information for the node.
propertyName Retrieve the computed style value for this property name. Return value The nsIDOMCSSPrimitiveValue computed style value. Exceptions thrown NS_ERROR_FAILURE Indicates that the access node is unattached from the accessible tree. getCom...
...tached from the accessible tree. getComputedStyleValue() Retrieve the computed style value for this DOM node, if it is a DOM element. Note: The meanings of width, height and other size measurements depend on the version of CSS being used. Therefore, for bounds information, it is better to use nsIAccessible.getBounds(). DOMString getComputedStyleValue( in DOMString pseudoElt, in DOMString
propertyName ); Parameters pseudoElt The pseudo element to retrieve style for, or null for general computed style information for this node.
propertyName Retrieve the computed style value for this property name, for example "border-bottom". Return value The computed style value. Exceptions thrown NS_ERROR_FAILURE Indicates that the access node is unattached from the accessible tree. scrollTo...
nsIDOMWindowUtils
ng long aOuterWindowID); long getPCCountScriptCount(); AString getPCCountScriptSummary(in long aScript); AString getPCCountScriptContents(in long aScript); void getScrollXY(in boolean aFlushLayout, out long aScrollX, out long aScrollY); AString getVisitedDependentComputedStyle(in nsIDOMElement aElement, in AString aPseudoElement, in AString a
PropertyName); boolean isInModalState(); void leaveModalState(); void loadSheet(in nsIURI sheetURI, in unsigned long type); nsIDOMNodeList nodesFromRect(in float aX, in float aY, in float aTopSize, in float aRightSize, in float aBottomSize, in float aLeftSize, in boolean aIgnoreRootScrollFrame, in boolean aFlushLayout); void processUpdates(); Obsolete since G...
...urns the scroll position of the window's currently loaded document. void getScrollXY( in boolean aFlushLayout, out long aScrollX, out long aScrollY ); Parameters aFlushLayout Flushes layout if true. Otherwise, no flush occurs. aScrollX aScrollY getVisitedDependentComputedStyle() Perform the equivalent of: window.getComputedStyle(aElement, aPseudoElement). getPropertyValue(a
PropertyName) except that, when the link whose presence in history is allowed to influence aElement's style is visited, get the value the property would have if allowed all properties to change as a result of :visited selectors (except for cases where getComputedStyle uses data from the frame). This is easier to implement than adding our property restrictions to this API, and is sufficient for the present te...
...change as a result of :visited selectors (except for cases where getComputedStyle uses data from the frame). This is easier to implement than adding our property restrictions to this API, and is sufficient for the present testing requirements (which are essentially testing 'color'). AString getVisitedDependentComputedStyle( in nsIDOMElement aElement, in AString aPseudoElement, in AString a
PropertyName ); Parameters aElement aPseudoElement a
PropertyName Return value isInModalState() Is the window is in a modal state? [See enterModalState()] boolean isInModalState(); Parameters None. Return value leaveModalState() Resume normal window state, where scripts can run and events are delivered. void leaveModalState(); Parameters None. loadSheet() Synchronously lo...
nsIMsgFolder
g msgName, in nsIMsgWindow msgWindow); AString getStringWithFolderNameFromBundle(in string msgName); void notifyCompactCompleted(); long compareSortKeys(in nsIMsgFolder msgFolder); [noscript] void getSortKey(out octet_ptr key, out unsigned long length); boolean callFilterPlugins(in nsIMsgWindow aMsgWindow); ACString getStringProperty(in string
propertyName); void setStringProperty(in string
propertyName, in ACString propertyValue); boolean isAncestorOf(in nsIMsgFolder folder); boolean containsChildNamed(in AString name); nsIMsgFolder getChildNamed(in AString aName); nsIMsgFolder findSubFolder(in ACString escapedSubFolderName); void AddFolderListener(in nsIFolderListener listener); void ...
... boolean isAncestorOf(in nsIMsgFolder folder); containsChildNamed() Looks in immediate children of this folder for the given name. boolean containsChildNamed(in AString name); getChil...
... boolean isAncestorOf(in nsIMsgFolder folder); containsChildNamed() Looks in immediate children of this folder for the given name. boolean containsChildNamed(in AString name); getChildNamed() Return the child folder which the specified name. nsIMsgFold...
nsISecurityCheckedComponent
s the "allAccess" capability, and no code has the "noAccess" capability. This interface is used in Mozilla by XPConnect and a handful of things that need special handing (XUL controllers, the UI for the <video> tag, etc.). Method overview string canCallMethod(in nsIIDPtr iid, in wstring methodName); string canCreateWrapper(in nsIIDPtr iid); string canGetProperty(in nsIIDPtr iid, in wstring
propertyName); string canSetProperty(in nsIIDPtr iid, in wstring
propertyName); Methods canCallMethod() Returns a capability string indicating what permissions are required to call the specified method on the given interface. string canCallMethod( in nsIIDPtr iid, in wstring methodName ); Parameters iid The IID of the interface this method exists on. methodName The name of the method to be called o...
... properties and methods will not be defined on the JavaScript object, whereas if wrapper creation succeeds but methods/properties are prevented, the properties and methods will be visible, not not usable. See Capability strings for details. canGetProperty() Returns the permissions required to get the specified property on the given interface. string canGetProperty( in nsIIDPtr iid, in wstring
propertyName ); Parameters iid The interface that the property to get exists on.
propertyName The name of the property to be retrieved on this interface. Return value The capability required to get the property. See Capability strings for details. canSetProperty() Returns the permissions required to set the specified property on the given interface. string canSetProperty( in nsIIDPtr iid, in wstring...
...); Parameters iid The interface that the property to get exists on.
propertyName The name of the property to be retrieved on this interface. Return value The capability required to get the property. See Capability strings for details. canSetProperty() Returns the permissions required to set the specified property on the given interface. string canSetProperty( in nsIIDPtr iid, in wstring
propertyName ); Parameters iid The interface that the property to set exists on.
propertyName The name of the property to be set on this interface. Return value The capability required to set the property. See Capability strings for details. ...
CSSStyleDeclaration.item() - Web APIs
The CSSStyleDeclaration.item() method interface returns a CSS property name from a CSSStyleDeclaration by index. This method doesn't throw exceptions as long as you provide arguments; the empty string is returned if the index is out of range and a TypeError is thrown if no argument is provided. Syntax var
propertyName = style.item(index); Parameters index is the index of the node to be fetched. The index is zero-based. ...
...returns a CSS property name from a CSSStyleDeclaration by index. This method doesn't throw exceptions as long as you provide arguments; the empty string is returned if the index is out of range and a TypeError is thrown if no argument is provided. Syntax var
propertyName = style.item(index); Parameters index is the index of the node to be fetched. The index is zero-based. Return value
propertyName is a DOMString that is the name of the CSS property at the specified index. ...
... of range and a TypeError is thrown if no argument is provided. Syntax var
propertyName = style.item(index); Parameters index is the index of the node to be fetched. The index is zero-based. Return value
propertyName is a DOMString that is the name of the CSS property at the specified index. JavaScript has a special simpler syntax for obtaining an item from a NodeList by index: var
propertyName = style[index]; Example var style = document.getElementById('div1').style; var
propertyName = style.item(1); // or simply style[1] - returns the second style listed Specifications Specification Status Comment CSS Object Model (CSSOM)The definition of 'CSSStyleDeclaration.item()' in that specification. Working Draft Document Object Model (DOM) Leve...
Grammar and types - JavaScript
og(car.manyCars.b); // Jeep console.log(car[7]); // Mazda Object property names can be any string, including the empty string. If the property name would not be a valid JavaScript identifier or number, it must be enclosed in quotes. Property names that are not valid identifiers cannot be accessed as a dot (.) property, but can be accessed and set with the array-like notation("[]"). ...
...es can be any string, including the empty string. If the property name would not be a valid JavaScript identifier or number, it must be enclosed in quotes. Property names that are not valid identifiers cannot be accessed as a dot (.) property, but can be accessed and set with the array-like notation("[]"). ...
...ld not be a valid JavaScript identifier or number, it must be enclosed in quotes. Property names that are not valid identifiers cannot be accessed as a dot (.) property, but can be accessed and set with the array-like notation("[]"). var unusual
PropertyNames = { '': 'An empty string', '!': 'Bang!' } console.log(unusual
PropertyNames.''); // SyntaxError: Unexpected string console.log(unusual
PropertyNames['']); // An empty string console.log(unusual
PropertyNames.!); // SyntaxError: Unexpected token ! console.log(unusual
PropertyNames['!']); // Bang! Enhanced Object literals In ES2015, object literals are extended to support setting the prototype at construction, shorthand for foo: foo assignments, defining methods, making super calls, and computing property names with expressions. Together,...
Regular expression syntax cheatsheet - JavaScript
it will stop as soon as it finds a match. ...
...o> <bar> new </bar> </foo> thing": /<.*>/ will match "<foo> <bar> new </bar> </foo>" /<.*?>/ will match "<foo>" Unicode property escapes If you are looking to contribute to this document, please also edit the original article // Non-binary values \p{UnicodePropertyValue} \p{Unicode
PropertyName=UnicodePropertyValue} // Binary and non-binary values \p{UnicodeBinary
PropertyName} // Negation: \P is negated \p \P{UnicodePropertyValue} \P{UnicodeBinary
PropertyName} UnicodeBinary
PropertyName The name of a binary property. E.g.: ASCII, Alpha, Math, Diacritic, Emoji, Hex_Digit, Math, White_space, etc. See Unicode Data PropList.txt for more info. Unicode
PropertyName The name of a non-binary property: General_Category (gc) Script (sc) Script_Extensions (scx) ...
...ame The name of a non-binary property: General_Category (gc) Script (sc) Script_Extensions (scx) See also PropertyValueAliases.txt UnicodePropertyValue One of the tokens listed in the Values section, below. Many values have aliases or shorthand (e.g. the value Decimal_Number for the General_Category property may be written Nd, digit, or Decimal_Number). For most values, the Unicode
PropertyName part and equals sign may be omitted. If a Unicode
PropertyName is specified, the value must correspond to the property type given. Note: As there are many properties and values available, we will not describe them exhaustively here but rather provide various examples ...
Unicode property escapes - JavaScript
.unicode. Note: Some Unicode properties encompasses much more characters than some character classes (such as \w which matches only latin letters, a to z) but the latter is better supported among browsers (as of January 2020). Syntax The following section is also duplicated on this cheatsheet. Do not forget to edit it as well, thanks! // Non-binary values \p{UnicodePropertyValue} \p{Unicode
PropertyName=UnicodePropertyValue} // Binary and non-binary values \p{UnicodeBinary
PropertyName} // Negation: \P is negated \p \P{UnicodePropertyValue} \P{UnicodeBinary
PropertyName} General_Category (gc) Script (sc) Script_Extensions (scx) See also PropertyValueAliases.txt UnicodeBinary
PropertyName The name of a binary property. E.g.: ASCII, Alpha, Math, Diacritic, Emoji, Hex_Digit, Math, White...
...Binary
PropertyName} // Negation: \P is negated \p \P{UnicodePropertyValue} \P{UnicodeBinary
PropertyName} General_Category (gc) Script (sc) Script_Extensions (scx) See also PropertyValueAliases.txt UnicodeBinary
PropertyName The name of a binary property. E.g.: ASCII, Alpha, Math, Diacritic, Emoji, Hex_Digit, Math, White_space, etc. See Unicode Data PropList.txt for more info. Unicode
PropertyName The name of a non-binary property: UnicodePropertyValue One of the tokens listed in the Values section, below. Many values have aliases or shorthand (e.g. the value Decimal_Number for the General_Category property may be written Nd, digit, or Decimal_Number). For most values, the Unicode
PropertyName part and equals sign may be omitted. ...
...opList.txt for more info. Unicode
PropertyName The name of a non-binary property: UnicodePropertyValue One of the tokens listed in the Values section, below. Many values have aliases or shorthand (e.g. the value Decimal_Number for the General_Category property may be written Nd, digit, or Decimal_Number). For most values, the Unicode
PropertyName part and equals sign may be omitted. If a Unicode
PropertyName is specified, the value must correspond to the property type given. Note: As there are many properties and values available, we will not describe them exhaustively here but rather provide various examples Rationale Before ES2018 there was no performance-efficient way to match characters from different sets based on scripts (like Macedonian, Greek, Georgian etc.) or
propertyName (like Emoji ...
handler.ownKeys() - JavaScript
rget, { ownKeys: function(target) { } }); Parameters The following parameter is passed to the ownKeys() method. this is bound to the handler. target The target object. Return value The ownKeys() method must return an enumerable object. Description The handler.ownKeys() method is a trap for Reflect.ownKeys(). Interceptions This trap can intercept these operations: Object.getOwn
PropertyNames() Object.getOwnPropertySymbols() Object.keys() Reflect.ownKeys() Invariants If the following invariants are violated, the proxy will throw a TypeError: The result of ownKeys() must be an array. The type of each array element is either a String or a Symbol. The result List must contain the keys of all non-configurable own properties of the target object. If the target object is not ex...
...peError: The result of ownKeys() must be an array. The type of each array element is either a String or a Symbol. The result List must contain the keys of all non-configurable own properties of the target object. If the target object is not extensible, then the result List must contain all the keys of the own properties of the target object and no other values. Examples Trapping of getOwn
PropertyNames The following code traps Object.getOwn
PropertyNames(). const p = new Proxy({}, { ownKeys: function(target) { console.log('called'); return ['a', 'b', 'c']; } }); console.log(Object.getOwn
PropertyNames(p)); // "called" // [ 'a', 'b', 'c' ] The following code violates an invariant. const obj = {}; Object.defineProperty(obj, 'a', { conf...
...ertyNames(p)); // "called" // [ 'a', 'b', 'c' ] The following code violates an invariant. const obj = {}; Object.defineProperty(obj, 'a', { configurable: false, enumerable: true, value: 10 } ); const p = new Proxy(obj, { ownKeys: function(target) { return [123, 12.5, true, false, undefined, null, {}, []]; } }); console.log(Object.getOwn
PropertyNames(p)); // TypeError: proxy [[OwnPropertyKeys]] must return an array // with only string and symbol elements Specifications Specification ECMAScript (ECMA-262)The definition of '[[OwnPropertyKeys]]' in that specification. ...
WebIDL bindings
n object is the object the property lookup is happening on (which may be an Xray for the actual DOM object) and the jsid is the property name. The value that the property should have is returned in the MutableHandle<Value>, with UndefinedValue() indicating that the property does not exist. If this extended attribute is used, then the underlying C++ class must also implement a method called GetOwn
PropertyNames with the signature void GetOwn
PropertyNames(JSContext* aCx, nsTArray<nsString>& aNames, ErrorResult& aRv). This method will be called by the JS engine's enumerate hook and must provide a superset of all the property names that DoResolve might resolve. Providing names that DoResolve won't actually resolve is OK. [HeaderFile="path/to/headerfile.h"] Indicates where the implementation can be found...
...know which content window it's associated with. The init method should not return anything. After this, the content-side object will be created. Then, if there are any constructor arguments, the object's __init method will be invoked, with the constructor arguments as its arguments. If you want an instance of the class to be added to window.navigator, add an extended attribute NavigatorProperty="
PropertyName" which will make the instance available as window.navigator.
PropertyName. Note that adding or removing NavigatorProperty requires a clobber. See https://bugzilla.mozilla.org/show_bug.cgi?id=1333117 for details. Static Members Static attributes and methods are not supported on JS-implemented WebIDL (see bug 863952). However, with the changes in bug 1172785 you can route static methods to a C+...
CSS.supports() - Web APIs
value A DOMString containing the value of the CSS property to check. The second syntax takes one parameter matching the condition of @supports: supportCondition A DOMString containing the condition to check. ...
... value A DOMString containing the value of the CSS property to check. The second syntax takes one parameter matching the condition of @supports: supportCondition A DOMString containing the condition to check. ...
CSSStyleDeclaration.setProperty() - Web APIs
value Optional is a DOMString containing the new property value. If not specified, treated as the empty string. Note: value must not contain "!important" -- that should be set using the priority parameter. priority Optional is a DOMString allowing the "important" CSS priority to be set. If not specified, treated as the empty string. ...
...tring. The following values are accepted: String value "important" Keyword undefined String empty value "" Return value undefined Exceptions DOMException (NoModificationAllowedError): if the property or declaration block is read only. If priority can be omitted, JavaScript has a special simpler syntax for setting a CSS property on a style declaration object: style.css
PropertyName = 'value'; Examples In this example we have three buttons, which can be pressed to dynamically alter our box paragraph's border, background color, and text color to random values (see the live example at the end of this section). We know that the rule we want to alter to do this is contained inside the second stylesheet applied to the page, so we grab a reference to it using document.styleShee...
Expressions and operators - JavaScript
ressions: Basic keywords and general expressions in JavaScript. Left-hand-side expressions: Left values are the destination of an assignment. Primary expressions Basic keywords and general expressions in JavaScript. this Use the this keyword to refer to the current object. In general, this refers to the calling object in a method. ...
...ords and general expressions in JavaScript. Left-hand-side expressions: Left values are the destination of an assignment. Primary expressions Basic keywords and general expressions in JavaScript. this Use the this keyword to refer to the current object. In general, this refers to the calling object in a method. ...
String.prototype.replace() - JavaScript
string are converted to lower case, and a hyphen is inserted just before the match location. The important thing here is that additional operations are needed on the matched item before it is given back as a replacement. The replacement function accepts the matched snippet as its parameter, and uses it to transform the case and concatenate the hyphen before returning. function styleHyphenFormat(
propertyName) { function upperToHyphenLower(match, offset, string) { return (offset > 0 ? '-' : '') + match.toLowerCase(); } return
propertyName.replace(/[A-Z]/g, upperToHyphenLower); } Given styleHyphenFormat('borderTop'), this returns 'border-top'. Because we want to further transform the result of the match before the final substitution is made, we must use a function. This forces the evaluati...
...henLower); } Given styleHyphenFormat('borderTop'), this returns 'border-top'. Because we want to further transform the result of the match before the final substitution is made, we must use a function. This forces the evaluation of the match prior to the toLowerCase() method. If we had tried to do this using the match without a function, the toLowerCase() would have no effect. let newString =
propertyName.replace(/[A-Z]/g, '-' + '$&'.toLowerCase()); // won't work This is because '$&'.toLowerCase() would first be evaluated as a string literal (resulting in the same '$&') before using the characters as a pattern. Replacing a Fahrenheit degree with its Celsius equivalent The following example replaces a Fahrenheit degree with its equivalent Celsius degree. The Fahrenheit degree should be a numbe...
core/heritage - Archive of obsolete content
} obscure Module exports obscure utility function that is useful for defining non-enumerable properties. Function takes an object and returns a new one in return that inherits from the same object as given one and implements all own properties of given object but as non-enumerable ones: var { obscure } = require('api-utils/heritage'); var object = mix({ a: 1 }, obscure({ b: 2 })); Object.getOwn
PropertyNames(foo); // => [ 'a' ] ...
NPN_GetProperty - Archive of obsolete content
<< Gecko Plugin API Reference << Scripting plugins Summary Gets the value of a property on the specified NPObject. Syntax #include <npruntime.h> bool NPN_GetProperty(NPP npp, NPObject *npobj, NPIdentifier
propertyName, NPVariant *result); Parameters The function has the following parameters: <tt>npp</tt> The NPP indicating which plugin instance's is making the request. <tt>npobj</tt> The object from which a value is to be retrieved. <tt>
propertyName</tt> A string identifier indicating the name of the property whose value is to be retrieved. <tt>result</tt> On return, contains the value of the specified property. Returns true if the value was retrieved successfully, otherwise false. Note: The caller must call NPN_ReleaseVariantValue() to release the returned value...
NPN_HasProperty - Archive of obsolete content
<< Gecko Plugin API Reference << Scripting plugins Summary Determines whether or not the specified NPObject has a particular property. Syntax #include <npruntime.h> bool NPN_HasProperty(NPP npp, NPObject *npobj, NPIdentifier
propertyName); Parameters The function has the following parameters: <tt>npp</tt> The NPP indicating which plugin instance is making the request. <tt>npobj</tt> The object on which to look for the property. <tt>
propertyName</tt> A string identifier indicating the name of the property to look for. Returns true if the property exists on the specified object, otherwise false. ...
NPN_RemoveProperty - Archive of obsolete content
<< Gecko Plugin API Reference << Scripting plugins Summary Removes a property from the specified NPObject. Syntax #include <npruntime.h> bool NPN_RemoveProperty(NPP npp, NPObject *npobj, NPIdentifier
propertyName); Parameters The function has the following parameters: npp The NPP indicating which plugin instance is making the request. npobj The object on which a property is to be deleted.
propertyName A string identifier indicating the name of the property to remove. Returns true if the property was removed successfully, otherwise false. ...
NPN_SetProperty - Archive of obsolete content
<< Gecko Plugin API Reference << Scripting plugins Summary Sets the value of a property on the specified NPObject. Syntax #include <npruntime.h> bool NPN_SetProperty(NPP npp, NPObject *npobj, NPIdentifier
propertyName, const NPVariant *value); Parameters The function has the following parameters: <tt>npp</tt> The NPP indicating which plugin instance's is making the request. <tt>npobj</tt> The object on which a value is to be set. <tt>
propertyName</tt> A string identifier indicating the name of the property whose value is to be set. <tt>value</tt> The value to store in the specified property. Returns true if the value was set successfully, otherwise false. ...
New in JavaScript 1.8.5 - Archive of obsolete content
the named properties described by the given descriptors to an object. Object.getOwnPropertyDescriptor() Returns a property descriptor for a named property on an object. bug 505587 Object.keys() Returns an array of all enumerable properties on an object. bug 307791 Object.getOwn
PropertyNames() Returns an array of all enumerable and non-enumerable properties on an object. bug 518663 Object.preventExtensions() Prevents any extensions of an object. bug 492849 Object.isExtensible() Determines if extending of an object is allowed. bug 492849 Object.seal() ...
Inheritance in JavaScript - Learn web development
are set via parameters. Setting Teacher()'s prototype and constructor reference All is good so far, but we have a problem. We have defined a new constructor, and it has a prototype property, which by default just contains an object with a reference to the constructor function itself. It does not contain the methods of the Person constructor's prototype property. To see this, enter Object.getOwn
PropertyNames(Teacher.prototype) into either the text input field or your JavaScript console. Then enter it again, replacing Teacher with Person. Nor does the new constructor inherit those methods. To see this, compare the outputs of Person.prototype.greeting and Teacher.prototype.greeting. We need to get Teacher() to inherit the methods defined on Person()'s prototype. So how do we do that? Add the follow...
Scripting Java
address this need, Rhino provides the ability to create new Java objects that implement interfaces. First we must define a JavaScript object with function properties whose names match the methods required by the Java interface. To implement a Runnable, we need only define a single method run with no parameters. If you remember from Chapter 3, it is possible to define a JavaScript object with the {
propertyName: value} notation. We can use that syntax here in combination with a function expression to define a JavaScript object with a run method: js> obj = { run: function () { print("\nrunning"); } } [object Object] js> obj.run() running Now we can create an object implementing the Runnable interface by constructing a Runnable: js> r = new java.lang.Runnable(obj); [object JavaObject] In Java it is...
Bytecode Descriptions
Pow Stack: lval, rval => (lval ** rval) The exponentiation operator (**). Pop two values, convert them to numeric values, do exponentiation, and push the result. The top value is the exponent. The conversion can call .toString()/.valueOf() methods and can throw. This throws a RangeError if both values are BigInts and the exponent is negative. Format: JOF_IC Conversions ToPropertyKey Stack:
propertyNameValue => propertyKey Convert a value to a property key. Implements: ToPropertyKey, except that if the result would be the string representation of some integer in the range 0..2^31, we push the corresponding Int32 value instead. This is because the spec insists that array indices are strings, whereas for us they are integers. This is used for code like ++obj[index], which must do both a JSOp::GetE...
Access StringBundle from Overlay
an existing stringbundleset as such: <stringbundleset id="stringbundleset"> <stringbundle src="chrome://your_extension/locale/overlay.properties" id="your-extension-strings" /> </stringbundleset> Now that your stringbundle is attached you can access it from JavaScript as follows: var str = document.getElementById("your-extension-strings"); //get the stringbundle object itself str.getString("
propertyName"); //get a string (and do something with it) Alternative way let stringBundleService = Cc["@mozilla.org/intl/stringbundle;1"].getService(Ci.nsIStringBundleService); let bundle = stringBundleService.createBundle("chrome://your_extension/locale/overlay.properties"); let str = bundle.GetStringFromName("
propertyName"); see nsIStringBundleService ...
Debugger.Object - Firefox Developer Tools
has no such property, return undefined. (This function behaves like the standard Object.getOwnPropertyDescriptor function, except that the object being inspected is implicit; the property descriptor returned is allocated as if by code scoped to the debugger's global object (and is thus in the debugger's compartment); and its value, get, and set properties, if present, are debuggee values.) getOwn
PropertyNames() Return an array of strings naming all the referent's own properties, as if Object.getOwn
PropertyNames(referent) had been called in the debuggee, and the result copied in the scope of the debugger's global object. getOwnPropertySymbols() Return an array of strings naming all the referent's own symbols, as if Object.getOwnPropertySymbols(referent) had been called in the debuggee, and the resu...
Debugger.Object - Firefox Developer Tools
s no such property, return undefined. (This function behaves like the standard Object.getOwnPropertyDescriptor function, except that the object being inspected is implicit; the property descriptor returned is allocated as if by code scoped to the debugger's global object (and is thus in the debugger's compartment); and its value, get, and set properties, if present, are debuggee values.) getOwn
PropertyNames() Return an array of strings naming all the referent's own properties, as if Object.getOwn
PropertyNames(referent) had been called in the debuggee, and the result copied in the scope of the debugger's global object. defineProperty(name,attributes) Define a property on the referent namedname, as described by the property descriptordescriptor. Any value, get, and set properties ofattribute...
AnimationEvent() - Web APIs
type A DOMString representing the name of the type of the AnimationEvent. It is case-sensitive and can be: 'animationstart', 'animationend', or 'animationiteration'. ...
Using dynamic styling information - Web APIs
desired CSS. Modify an element's style The element style property (see also the section "DOM Style Object" below) can also be used to get and set the styles on an element. However, this property only returns style attributes that have been set in-line (e.g, <td style="background-color: lightblue"> returns the string "background-color:lightblue", or directly for that element using element.style.
propertyName, even though there may be other styles on the element from a stylesheet). Also, when you set this property on an element, you override any styles that have been set elsewhere for that element's particular property you are setting. Setting the border property, for example, will override settings made elsewhere for that element's border property in the head section, or external style sheets. Howev...
Using the CSS Painting API - Web APIs
width to change the size of the background image. In browsers that support the CSS Paint API, the example below should appear like the image above. Custom properties In addition to accessing the size of the element, the worklet can also have access to CSS custom properties and regular CSS properties. registerPaint('cssPaintFunctionName', class { static get inputProperties() { return ['
PropertyName1', '--custom
PropertyName2']; } static get inputArguments() { return ['<color>']; } static get contextOptions() { return {alpha: true}; } paint(drawingContext, elementSize, styleMap) { // Paint code goes here. } }); The three parameters of the paint() function include the drawing context, paint size and properties. To be able to access properties, we include the sta...
Using the CSS Typed Object Model - Web APIs
ntent. Open up this example in Codepen or JSFiddle, and change some features. Try adding some CSS, such as a width for this paragraph, or adding a CSS property to the ofInterst array. </p> <table id="regurgitation"> <thead> <tr> <th>Property</th> <th>Value</th> <th>Unit</th> </tr> </table> For each property of interest, we list the name of the property, use .get(
propertyName).value to return the value, and, if the object returned by the get() is a CSSUnitValue, list the unit type we retrieve with .get(
propertyName).unit. // get the element we're inspecting const myElement = document.querySelector('p'); // get the table we'll be populating const stylesTable = document.querySelector('#regurgitation'); // Retrieve all computed styles with computedStyleMap() const all...
Element.classList - Web APIs
is){ this[i-1]=this[i] }else{ if(this[i] !== val){ resStr+=this[i]+" "; }else{ is=1; } } if (!is) continue; delete this[Len], proto.length -= 1, proto.value = resStr; } skipPropChange = 1, ele.className = proto.value, skipPropChange = 0; }; window.DOMTokenList = DOMTokenList; function whenPropChanges(){ var evt = window.event, prop = evt.
propertyName; if ( !skipPropChange && (prop==="className" || (prop==="classList" && !defineProperty)) ) { var target = evt.srcElement, protoObjProto = target[" uCLp"], strval = "" + target[prop]; var tokens=strval.trim().split(wsRE), resTokenList=target[prop==="classList"?" uCL":"classList"]; var oldLen = protoObjProto.length; a: for(var cI = 0, cLen = p...
PaymentResponse.onpayerdetailchange - Web APIs
date.push(validatePhone(payerPhone)); oldPayerPhone = payerPhone; } // As each validation promise resolves, add the results of the // validation to the errors list const errors = await Promise.all(promisesToValidate).then(results => results.reduce((errors, result), Object.assign(errors, result)) ); // If we found any errors, wait for them to be corrected if (Object.getOwn
PropertyNames(errors).length) { await response.retry(errors); } else { // We have a good payment; send the data to the server await fetch("/pay-for-things/", { method: "POST", body: response.json() }); response.complete("success"); } }; await response.retry({ payer: { email: "invalid domain.", phone: "invalid number.", }, }); Specifications Specification Status ...
PaymentResponse: payerdetailchange event - Web APIs
date.push(validatePhone(payerPhone)); oldPayerPhone = payerPhone; } // As each validation promise resolves, add the results of the // validation to the errors list const errors = await Promise.all(promisesToValidate).then(results => results.reduce((errors, result), Object.assign(errors, result)) ); // If we found any errors, wait for them to be corrected if (Object.getOwn
PropertyNames(errors).length) { await response.retry(errors); } else { // We have a good payment; send the data to the server await fetch("/pay-for-things/", { method: "POST", body: response.json() }); response.complete("success"); } }; await response.retry({ payer: { email: "invalid domain.", phone: "invalid number.", }, }); addEventListener equivalent You could also set u...
TransitionEvent() - Web APIs
The TransitionEvent() constructor returns a newly created TransitionEvent, representing an event in relation with an transition. Syntax transitionEvent = new TransitionEvent(type, {
propertyName: a
PropertyName, elapsedTime : aFloat, pseudoElement: aPseudoElementName}); Arguments The TransitionEvent() constructor also inherits arguments from Event(). type Is a DOMString representing the name of the type of the TransitionEvent. It is case-sensitive and can only be: 'transitionend'.
propertyName Optional Is a DOMString containing the value of the property-name CSS property associated with the transition. It defaults to "". elapsedTime Optional Is float giving the amount of time the animation has ...
TransitionEvent - Web APIs
TransitionEvent.elapsedTime Read only Is a float giving the amount of time the transition has been running, in seconds, when this event fired. ...
msPutPropertyEnabled - Web APIs
acing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future. The msPutPropertyEnabled method sets whether a given property in the style object is enabled or disabled. This proprietary method is specific to Internet Explorer and Microsoft Edge. Syntax var retval = style.msPutPropertyEnabled(
propertyName, true); Parameters name[in]: Name of the property. (String) boolean[in]: True = Enable the property. False = Disable the property. Return value Type = HRESULT: If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. See also CSS Style Declaration Microsoft API extensions ...
Using CSS transitions - CSS: Cascading Style Sheets
px; background: #c00; position: absolute; top: 0; left: 0; transition: transform 1s; } You can play with this here: http://jsfiddle.net/9h261pzo/291/ Detecting the start and completion of a transition You can use the transitionend event to detect that an animation has finished running. This is a TransitionEvent object, which has two added properties beyond a typical Event object:
propertyName A string indicating the name of the CSS property whose transition completed. elapsedTime A float indicating the number of seconds the transition had been running at the time the event fired. This value isn't affected by the value of transition-delay. As usual, you can use the addEventListener() method to monitor for this event: el.addEventListener("transitionend", updateTransition, true); ...
Meta programming - JavaScript
e proxy[foo] delete proxy.foo Reflect.deleteProperty() A property cannot be deleted if it exists as a non-configurable own property of target. handler.enumerate() Property enumeration / for...in: for (let name in proxy) {...} Reflect.enumerate() The enumerate method must return an object. handler.ownKeys() Object.getOwn
PropertyNames() Object.getOwnPropertySymbols() Object.keys() Reflect.ownKeys() The result of ownKeys is a List. The Type of each result List element is either String or Symbol. The result List must contain the keys of all non-configurable own properties of target. If the target object is not extensible, then the result List must contain all the keys of the own properti...
Deprecated and obsolete features - JavaScript
the deprecated toGMTString method in new code. toLocaleFormat is deprecated. Functions Expression closures are deprecated. Use regular functions or arrow functions instead. Proxy Proxy.create and Proxy.createFunction are deprecated. Use Proxy instead. The following traps are obsolete: hasOwn (bug 980565, Firefox 33). getEnumerablePropertyKeys (bug 783829, Firefox 37) getOwn
PropertyNames (bug 1007334, Firefox 33) keys (bug 1007334, Firefox 33) Escape sequences Octal escape sequences (\ followed by one, two, or three octal digits) are deprecated in string and regular expression literals. The escape and unescape functions are deprecated. Use encodeURI, encodeURIComponent, decodeURI or decodeURIComponent to encode and decode escape sequences for special characters. ...
Warning: String.x is deprecated; use String.prototype.x instead - JavaScript
rd syntax var num = 15; String(num).replace(/5/, '2'); Shim The following is a shim to provide support to non-supporting browsers: /*globals define*/ // Assumes all supplied String instance methods already present // (one may use shims for these if not available) (function() { 'use strict'; var i, // We could also build the array of methods with the following, but the // getOwn
PropertyNames() method is non-shimable: // Object.getOwn
PropertyNames(String).filter(function(methodName) { // return typeof String[methodName] === 'function'; // }); methods = [ 'contains', 'substring', 'toLowerCase', 'toUpperCase', 'charAt', 'charCodeAt', 'indexOf', 'lastIndexOf', 'startsWith', 'endsWith', 'trim', 'trimLeft', 'trimRight', 'toLocaleLowerCase', 'normalize',...
Array.prototype.forEach() - JavaScript
An object copy function The following code creates a copy of a given object. There are different ways to create a copy of an object. The following is just one way and is presented to explain how Array.prototype.forEach() works by using ECMAScript 5 Object.* meta property functions. function copy(obj) { const copy = Object.create(Object.getPrototypeOf(obj)) const propNames = Object.getOwn
PropertyNames(obj) propNames.forEach((name) => { const desc = Object.getOwnPropertyDescriptor(obj, name) Object.defineProperty(copy, name, desc) }) return copy } const obj1 = { a: 1, b: 2 } const obj2 = copy(obj1) // obj2 looks like obj1 now Modifying the array during iteration The following example logs one, two, four. When the entry containing the value two is reached, the first entry o...
Object.freeze() - JavaScript
e() would be to have an internal function that receives a path (e.g. an Array) argument so you can suppress calling deepFreeze() recursively when an object is in the process of being made immutable. You still run a risk of freezing an object that shouldn't be frozen, such as [window]. ...
Object.getOwnPropertySymbols() - JavaScript
tory. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. Syntax Object.getOwnPropertySymbols(obj) Parameters obj The object whose symbol properties are to be returned. Return value An array of all symbol properties found directly upon the given object. Description Similar to Object.getOwn
PropertyNames(), you can get all symbol properties of a given object as an array of symbols. Note that Object.getOwn
PropertyNames() itself does not contain the symbol properties of an object and only the string properties. As all objects have no own symbol properties initially, Object.getOwnPropertySymbols() returns an empty array unless you have set symbol properties on your object. Examples Using getOwnP...
Object.prototype.hasOwnProperty() - JavaScript
the properties of an object The following example shows how to iterate over the properties of an object without executing on inherited properties. Note that the for...in loop is already only iterating enumerable items, so one should not assume based on the lack of non-enumerable properties shown in the loop that hasOwnProperty itself is confined strictly to enumerable items (as with Object.getOwn
PropertyNames()). var buz = { fog: 'stack' }; for (var name in buz) { if (buz.hasOwnProperty(name)) { console.log('this is fog (' + name + ') for sure. Value: ' + buz[name]); } else { console.log(name); // toString or something else } } Using hasOwnProperty as a property name JavaScript does not protect the property name hasOwnProperty; thus, if the possibility exists that an obje...
Object.keys() - JavaScript
Non-object coercion In ES5, if the argument to this method is not an object (a primitive), then it will cause a TypeError. From ES2015 onwards, a non-object argument will be coerced to an object. // In ES5 Object.keys('foo'); // TypeError: "foo" is not an object // In ES2015+ Object.keys('foo'); // ["0", "1", "2"] Specifications Specification ECMAScript (ECMA-2...
Object - JavaScript
ther code cannot delete or change its properties. Object.fromEntries() Returns a new object from an iterable of [key, value] pairs. (This is the reverse of Object.entries). Object.getOwnPropertyDescriptor() Returns a property descriptor for a named property on an object. Object.getOwnPropertyDescriptors() Returns an object containing all own property descriptors for an object. Object.getOwn
PropertyNames() Returns an array containing the names of all of the given object's own enumerable and non-enumerable properties. Object.getOwnPropertySymbols() Returns an array of all symbol properties found directly upon a given object. Object.getPrototypeOf() Returns the prototype (internal [[Prototype]] property) of the specified object. Object.is() Compares if two values are the same value. Equates...
Proxy() constructor - JavaScript
. handler.deleteProperty() A trap for the delete operator. handler.get() A trap for getting property values. handler.getOwnPropertyDescriptor() A trap for Object.getOwnPropertyDescriptor. handler.getPrototypeOf() A trap for Object.getPrototypeOf. handler.has() A trap for the in operator. handler.isExtensible() A trap for Object.isExtensible. handler.ownKeys() A trap for Object.getOwn
PropertyNames and Object.getOwnPropertySymbols. handler.preventExtensions() A trap for Object.preventExtensions. handler.set() A trap for setting property values. handler.setPrototypeOf() A trap for Object.setPrototypeOf. Examples Selectively proxy property accessors In this example the target has two properties, notProxied and proxied. We define a handler that returns a different value for proxied,...
Reflect.ownKeys() - JavaScript
send us a pull request. Syntax Reflect.ownKeys(target) Parameters target The target object from which to get the own keys. Return value An Array of the target object's own property keys. Exceptions A TypeError, if target is not an Object. Description The Reflect.ownKeys method returns an array of the target object's own property keys. Its return value is equivalent to Object.getOwn
PropertyNames(target).concat(Object.getOwnPropertySymbols(target)). Examples Using Reflect.ownKeys() Reflect.ownKeys({z: 3, y: 2, x: 1}) // [ "z", "y", "x" ] Reflect.ownKeys([]) // ["length"] let sym = Symbol.for('comet') let sym2 = Symbol.for('meteor') let obj = {[sym]: 0, 'str': 0, '773': 0, '0': 0, [sym2]: 0, '-1': 0, '8': 0, 'second str': 0} Reflect.ownKeys(obj) // [ "0", ...
Symbol - JavaScript
hrows a TypeError (can't convert symbol to string). This prevents you from silently creating a new string property name from a symbol, for example. The "safer" String(sym) conversion works like a call to Symbol.prototype.toString() with symbols, but note that new String(sym) will throw. Symbols and for...in iteration Symbols are not enumerable in for...in iterations. In addition, Object.getOwn
PropertyNames() will not return symbol object properties, however, you can use Object.getOwnPropertySymbols() to get these. let obj = {} obj[Symbol('a')] = 'a' obj[Symbol.for('b')] = 'b' obj['c'] = 'c' obj.d = 'd' for (let i in obj) { console.log(i) // logs "c" and "d" } Symbols and JSON.stringify() Symbol-keyed properties will be completely ignored when using JSON.stringify(): JSON.stringify({[Symb...
this - JavaScript
ss context The behavior of this in classes and functions is similar, since classes are functions under the hood. But there are some differences and caveats. Within a class constructor, this is a regular object. All non-static methods within the class are added to the prototype of this: class Example { constructor() { const proto = Object.getPrototypeOf(this); console.log(Object.getOwn
PropertyNames(proto)); } first(){} second(){} static third(){} } new Example(); // ['constructor', 'first', 'second'] Note: Static methods are not properties of this. They are properties of the class itself. Derived classes Unlike base class constructors, derived constructors have no initial this binding. Calling super() creates a this binding within the constructor and essentially has the eff...
for...in - JavaScript
dent, iterating over an array may not visit elements in a consistent order. Therefore, it is better to use a for loop with a numeric index (or Array.prototype.forEach() or the for...of loop) when iterating over arrays where the order of access is important. Iterating over own properties only If you only want to consider properties attached to the object itself, and not its prototypes, use getOwn
PropertyNames() or perform a hasOwnProperty() check (propertyIsEnumerable() can also be used). Alternatively, if you know there won't be any outside code interference, you can extend built-in prototypes with a check method. Why Use for...in? Given that for...in is built for iterating object properties, not recommended for use with arrays, and options like Array.prototype.forEach() and for...of exist, what m...