From d5fc4fceb53fa5bc45e7a6dd4bc2de90dfdaa653 Mon Sep 17 00:00:00 2001 From: Stephane Moreau Date: Fri, 20 Apr 2018 00:05:42 +0100 Subject: [PATCH] keep the javascript cheatsheet into one single file --- README.md | 9 +--- .../{javascript/arrays.js => javascript.js} | 45 ++++++++++++++++++- languages/javascript/objects.js | 44 ------------------ 3 files changed, 45 insertions(+), 53 deletions(-) rename languages/{javascript/arrays.js => javascript.js} (53%) delete mode 100644 languages/javascript/objects.js diff --git a/README.md b/README.md index 0f66519..d526aa4 100644 --- a/README.md +++ b/README.md @@ -29,14 +29,7 @@ Feel free to browse each cheatsheet to learn new things and to keep them at hand #### Functional -
- JavaScript - -* [Objects](languages/javascript/objects.js) - -* [Arrays](languages/javascript/arrays.js) - -
+* [JavaScript](languages/javaScript.js) diff --git a/languages/javascript/arrays.js b/languages/javascript.js similarity index 53% rename from languages/javascript/arrays.js rename to languages/javascript.js index fa7a5e2..932893e 100644 --- a/languages/javascript/arrays.js +++ b/languages/javascript.js @@ -1,9 +1,52 @@ +/* ******************************************************************************************* + * GLOBAL OBJECTS > OBJECT + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object + * ******************************************************************************************* */ + +// Global object: properties +Object.length // length is a property of a function object, and indicates how many arguments the function expects, i.e. the number of formal parameters. This number does not include the rest parameter. Has a value of 1. +Object.prototype // Represents the Object prototype object and allows to add new properties and methods to all objects of type Object. + +// Methods of the Object constructor +Object.assign(target, ...sources) // Copies the values of all enumerable own properties from one or more source objects to a target object. method is used to copy the values of all enumerable own properties from one or more source objects to a target object. It will return the target object +Object.create(MyObject) // Creates a new object with the specified prototype object and properties. The object which should be the prototype of the newly-created object. +Object.defineProperty(obj, prop, descriptor) // Adds the named property described by a given descriptor to an object. +Object.defineProperties(obj, props) // Adds the named properties described by the given descriptors to an object. +Object.entries(obj) // Returns an array containing all of the [key, value] pairs of a given object's own enumerable string properties. +Object.freeze(obj) // Freezes an object: other code can't delete or change any properties. +Object.getOwnPropertyDescriptor(obj, prop) // Returns a property descriptor for a named property on an object. +Object.getOwnPropertyDescriptors(obj) // Returns an object containing all own property descriptors for an object. +Object.getOwnPropertyNames(obj) // Returns an array containing the names of all of the given object's own enumerable and non-enumerable properties. +Object.getOwnPropertySymbols(obj) // Returns an array of all symbol properties found directly upon a given object. +Object.getPrototypeOf(obj) // Returns the prototype of the specified object. +Object.is(value1, value2); // Compares if two values are the same value. Equates all NaN values (which differs from both Abstract Equality Comparison and Strict Equality Comparison). +Object.isExtensible(obj) // Determines if extending of an object is allowed. +Object.isFrozen(obj) // Determines if an object was frozen. +Object.isSealed(obj) // Determines if an object is sealed. +Object.keys(obj) // Returns an array containing the names of all of the given object's own enumerable string properties. +Object.preventExtensions(obj) // Prevents any extensions of an object. +Object.seal(obj) // Prevents other code from deleting properties of an object. +Object.setPrototypeOf(obj, prototype) // Sets the prototype (i.e., the internal [[Prototype]] property). +Object.values(obj) // Returns an array containing the values that correspond to all of a given object's own enumerable string properties. + +// Object instances and Object prototype object (Object.prototype.property or Object.prototype.method()) +// Properties +obj.constructor // Specifies the function that creates an object's prototype. +obj.__proto__ // Points to the object which was used as prototype when the object was instantiated. + +// Methods +obj.hasOwnProperty(prop) // Returns a boolean indicating whether an object contains the specified property as a direct property of that object and not inherited through the prototype chain. +prototypeObj.isPrototypeOf(object) // Returns a boolean indicating whether the object this method is called upon is in the prototype chain of the specified object. +obj.propertyIsEnumerable(prop) // Returns a boolean indicating if the internal ECMAScript [[Enumerable]] attribute is set. +obj.toLocaleString() // Calls toString(). +obj.toString() // Returns a string representation of the object. +object.valueOf() // Returns the primitive value of the specified object. + /* ******************************************************************************************* * GLOBAL OBJECTS > ARRAY * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array * ******************************************************************************************* */ - // Global object: properties Array.length // Reflects the number of elements in an array. Array.prototype // Represents the prototype for the Array constructor and allows to add new properties and methods to all Array objects. diff --git a/languages/javascript/objects.js b/languages/javascript/objects.js deleted file mode 100644 index 982a734..0000000 --- a/languages/javascript/objects.js +++ /dev/null @@ -1,44 +0,0 @@ -/* ******************************************************************************************* - * GLOBAL OBJECTS > OBJECT - * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object - * ******************************************************************************************* */ - -// Global object: properties -Object.length // length is a property of a function object, and indicates how many arguments the function expects, i.e. the number of formal parameters. This number does not include the rest parameter. Has a value of 1. -Object.prototype // Represents the Object prototype object and allows to add new properties and methods to all objects of type Object. - -// Methods of the Object constructor -Object.assign(target, ...sources) // Copies the values of all enumerable own properties from one or more source objects to a target object. method is used to copy the values of all enumerable own properties from one or more source objects to a target object. It will return the target object -Object.create(MyObject) // Creates a new object with the specified prototype object and properties. The object which should be the prototype of the newly-created object. -Object.defineProperty(obj, prop, descriptor) // Adds the named property described by a given descriptor to an object. -Object.defineProperties(obj, props) // Adds the named properties described by the given descriptors to an object. -Object.entries(obj) // Returns an array containing all of the [key, value] pairs of a given object's own enumerable string properties. -Object.freeze(obj) // Freezes an object: other code can't delete or change any properties. -Object.getOwnPropertyDescriptor(obj, prop) // Returns a property descriptor for a named property on an object. -Object.getOwnPropertyDescriptors(obj) // Returns an object containing all own property descriptors for an object. -Object.getOwnPropertyNames(obj) // Returns an array containing the names of all of the given object's own enumerable and non-enumerable properties. -Object.getOwnPropertySymbols(obj) // Returns an array of all symbol properties found directly upon a given object. -Object.getPrototypeOf(obj) // Returns the prototype of the specified object. -Object.is(value1, value2); // Compares if two values are the same value. Equates all NaN values (which differs from both Abstract Equality Comparison and Strict Equality Comparison). -Object.isExtensible(obj) // Determines if extending of an object is allowed. -Object.isFrozen(obj) // Determines if an object was frozen. -Object.isSealed(obj) // Determines if an object is sealed. -Object.keys(obj) // Returns an array containing the names of all of the given object's own enumerable string properties. -Object.preventExtensions(obj) // Prevents any extensions of an object. -Object.seal(obj) // Prevents other code from deleting properties of an object. -Object.setPrototypeOf(obj, prototype) // Sets the prototype (i.e., the internal [[Prototype]] property). -Object.values(obj) // Returns an array containing the values that correspond to all of a given object's own enumerable string properties. - -// Object instances and Object prototype object (Object.prototype.property or Object.prototype.method()) -// Properties -obj.constructor // Specifies the function that creates an object's prototype. -obj.__proto__ // Points to the object which was used as prototype when the object was instantiated. - -// Methods -obj.hasOwnProperty(prop) // Returns a boolean indicating whether an object contains the specified property as a direct property of that object and not inherited through the prototype chain. -prototypeObj.isPrototypeOf(object) // Returns a boolean indicating whether the object this method is called upon is in the prototype chain of the specified object. -obj.propertyIsEnumerable(prop) // Returns a boolean indicating if the internal ECMAScript [[Enumerable]] attribute is set. -obj.toLocaleString() // Calls toString(). -obj.toString() // Returns a string representation of the object. -object.valueOf() // Returns the primitive value of the specified object. -