SlideShare a Scribd company logo
JavaScript OBJECT
Object.create() method creates a new object with the specified prototype
object and properties.
Syntax
Object.create(proto[, propertiesObject])
function Car (desc) {
this.desc = desc;
this.color = "red";
}
Car.prototype = {
getInfo: function() {
return 'A ' + this.color + ' ' + this.desc + '.';
}
};
//instantiate object using the constructor function
var car = Object.create(Car.prototype);
car.color = "blue";
alert(car.getInfo());
Object.defineProperties() method defines new or modifies existing
properties directly on an object, returning the object.
Syntax
Object.defineProperties(obj, props)
var obj = {};
Object.defineProperties(obj, {
'property1': {
value: true,
writable: true
},
'property2': {
value: 'Hello',
writable: false
}
// etc. etc.
});
Object.defineProperty() method defines a new property directly on an
object, or modifies an existing property on an object, and returns the object.
Syntax
Object.defineProperty(obj, prop, descriptor)
Parameters
obj
The object on which to define the property.
prop
The name of the property to be defined or modified.
descriptor
The descriptor for the property being defined or modified.
var o = {}; // Creates a new object
// Example of an object property added
// with defineProperty with a data property descriptor
Object.defineProperty(o, 'a', {
value: 37,
writable: true,
enumerable: true,
configurable: true
});
Object.entries() method returns an array of a given object's own enumerable
property [key, value] pairs, in the same order as that provided by a for...in loop
(the difference being that a for-in loop enumerates properties in the prototype
chain as well).
Syntax
Object.entries(obj)
var obj = { soap: 'bar', baz: 42 };
console.log(Object.entries(obj)); // [ [soap, 'bar'], ['baz', 42] ]
Object.keys() method returns an array of a given object's own enumerable
properties, in the same order as that provided by a for...in loop (the difference
being that a for-in loop enumerates properties in the prototype chain as well).
Syntax
Object.keys(obj)
Parameters
obj
The object of which the enumerable own properties are to be returned.
var arr = ['a', 'b', 'c'];
console.log(Object.keys(arr)); // console: ['0', '1', '2']
Object.assign() 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.
Syntax
Object.assign(target, ...sources)
Parameters
target
The target object.
sources
The source object(s).
var obj = { a: 1 };
var copy = Object.assign({}, obj);
console.log(copy); // { a: 1 }
Object.isSealed() method determines if an object is sealed.
Syntax
Object.isSealed(obj)
Parameters
obj
The object which should be checked.
var empty = {};
Object.isSealed(empty); // === false
// If you make an empty object non-extensible,
// it is vacuously sealed.
Object.preventExtensions(empty);
Object.isSealed(empty); // === true

More Related Content

PPTX
Object Oriented JavaScript
Julie Iskander
 
PPTX
11. session 11 functions and objects
Phúc Đỗ
 
PPTX
JavaScript (without DOM)
Piyush Katariya
 
PPTX
Learn JS concepts by implementing jQuery
Wingify Engineering
 
PDF
Javascript closures
VNG
 
PDF
Java Script Workshop
Dmitry Baranovskiy
 
PDF
«Objective-C Runtime в примерах» — Алексей Сторожев, e-Legion
e-Legion
 
PDF
Functional Core, Reactive Shell
Giovanni Lodi
 
Object Oriented JavaScript
Julie Iskander
 
11. session 11 functions and objects
Phúc Đỗ
 
JavaScript (without DOM)
Piyush Katariya
 
Learn JS concepts by implementing jQuery
Wingify Engineering
 
Javascript closures
VNG
 
Java Script Workshop
Dmitry Baranovskiy
 
«Objective-C Runtime в примерах» — Алексей Сторожев, e-Legion
e-Legion
 
Functional Core, Reactive Shell
Giovanni Lodi
 

Similar to JavaScript Object API (20)

PPTX
Defining method in JavaScript object.pptx
Steins18
 
PDF
[A 3]Javascript oop for xpages developers - public
Kazunori Tatsuki
 
PPTX
Oojs 1.1
Rodica Dada
 
PPTX
OO in JavaScript
Gunjan Kumar
 
PDF
Let's JavaScript
Paweł Dorofiejczyk
 
PDF
Say It With Javascript
Giovanni Scerra ☃
 
DOCX
descriptive programming
Anand Dhana
 
PDF
Javascript
Aditya Gaur
 
PPT
Advanced Javascript
Adieu
 
PPT
Advanced Javascript
Manikanda kumar
 
PPT
Advanced Javascript
relay12
 
PPTX
Qtp training session IV
Aisha Mazhar
 
PPTX
Prototype Framework
Julie Iskander
 
KEY
Object-Oriented JavaScript
kvangork
 
KEY
Object-Oriented Javascript
kvangork
 
PPT
DESIGNING A PERSISTENCE FRAMEWORK WITH PATTERNS.ppt
AntoJoseph36
 
PDF
Node Architecture and Getting Started with Express
jguerrero999
 
PDF
Oo
fangdeng
 
PDF
舒舒服服的写Java script
fangdeng
 
PDF
舒舒服服的写Javascript
fangdeng
 
Defining method in JavaScript object.pptx
Steins18
 
[A 3]Javascript oop for xpages developers - public
Kazunori Tatsuki
 
Oojs 1.1
Rodica Dada
 
OO in JavaScript
Gunjan Kumar
 
Let's JavaScript
Paweł Dorofiejczyk
 
Say It With Javascript
Giovanni Scerra ☃
 
descriptive programming
Anand Dhana
 
Javascript
Aditya Gaur
 
Advanced Javascript
Adieu
 
Advanced Javascript
Manikanda kumar
 
Advanced Javascript
relay12
 
Qtp training session IV
Aisha Mazhar
 
Prototype Framework
Julie Iskander
 
Object-Oriented JavaScript
kvangork
 
Object-Oriented Javascript
kvangork
 
DESIGNING A PERSISTENCE FRAMEWORK WITH PATTERNS.ppt
AntoJoseph36
 
Node Architecture and Getting Started with Express
jguerrero999
 
舒舒服服的写Java script
fangdeng
 
舒舒服服的写Javascript
fangdeng
 
Ad

More from SRINIVAS KOLAPARTHI (6)

PDF
Salesforce Lightning Message Service.pdf
SRINIVAS KOLAPARTHI
 
PDF
Service Discovery in MicroServices
SRINIVAS KOLAPARTHI
 
PDF
Javascript Exercises
SRINIVAS KOLAPARTHI
 
PDF
Zuul_Intro.pdf
SRINIVAS KOLAPARTHI
 
PDF
MultiThreading in Python
SRINIVAS KOLAPARTHI
 
PDF
Salesforce LWC Toast Message
SRINIVAS KOLAPARTHI
 
Salesforce Lightning Message Service.pdf
SRINIVAS KOLAPARTHI
 
Service Discovery in MicroServices
SRINIVAS KOLAPARTHI
 
Javascript Exercises
SRINIVAS KOLAPARTHI
 
Zuul_Intro.pdf
SRINIVAS KOLAPARTHI
 
MultiThreading in Python
SRINIVAS KOLAPARTHI
 
Salesforce LWC Toast Message
SRINIVAS KOLAPARTHI
 
Ad

Recently uploaded (20)

PDF
Event Presentation Google Cloud Next Extended 2025
minhtrietgect
 
PDF
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
PDF
Brief History of Internet - Early Days of Internet
sutharharshit158
 
PPTX
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
PDF
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
PDF
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
PDF
Doc9.....................................
SofiaCollazos
 
PPTX
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
PDF
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
PPTX
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
PDF
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PDF
The Future of Artificial Intelligence (AI)
Mukul
 
PDF
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
Artjoker Software Development Company
 
PDF
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
PDF
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
PPTX
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
PDF
REPORT: Heating appliances market in Poland 2024
SPIUG
 
PPTX
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
PDF
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
Event Presentation Google Cloud Next Extended 2025
minhtrietgect
 
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
Brief History of Internet - Early Days of Internet
sutharharshit158
 
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
Doc9.....................................
SofiaCollazos
 
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
The Future of Artificial Intelligence (AI)
Mukul
 
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
Artjoker Software Development Company
 
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
REPORT: Heating appliances market in Poland 2024
SPIUG
 
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 

JavaScript Object API

  • 1. JavaScript OBJECT Object.create() method creates a new object with the specified prototype object and properties. Syntax Object.create(proto[, propertiesObject]) function Car (desc) { this.desc = desc; this.color = "red"; } Car.prototype = { getInfo: function() { return 'A ' + this.color + ' ' + this.desc + '.'; } }; //instantiate object using the constructor function var car = Object.create(Car.prototype); car.color = "blue"; alert(car.getInfo()); Object.defineProperties() method defines new or modifies existing properties directly on an object, returning the object. Syntax Object.defineProperties(obj, props) var obj = {}; Object.defineProperties(obj, { 'property1': { value: true,
  • 2. writable: true }, 'property2': { value: 'Hello', writable: false } // etc. etc. }); Object.defineProperty() method defines a new property directly on an object, or modifies an existing property on an object, and returns the object. Syntax Object.defineProperty(obj, prop, descriptor) Parameters obj The object on which to define the property. prop The name of the property to be defined or modified. descriptor The descriptor for the property being defined or modified. var o = {}; // Creates a new object // Example of an object property added // with defineProperty with a data property descriptor Object.defineProperty(o, 'a', { value: 37, writable: true, enumerable: true,
  • 3. configurable: true }); Object.entries() method returns an array of a given object's own enumerable property [key, value] pairs, in the same order as that provided by a for...in loop (the difference being that a for-in loop enumerates properties in the prototype chain as well). Syntax Object.entries(obj) var obj = { soap: 'bar', baz: 42 }; console.log(Object.entries(obj)); // [ [soap, 'bar'], ['baz', 42] ] Object.keys() method returns an array of a given object's own enumerable properties, in the same order as that provided by a for...in loop (the difference being that a for-in loop enumerates properties in the prototype chain as well). Syntax Object.keys(obj) Parameters obj The object of which the enumerable own properties are to be returned. var arr = ['a', 'b', 'c']; console.log(Object.keys(arr)); // console: ['0', '1', '2'] Object.assign() 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.
  • 4. Syntax Object.assign(target, ...sources) Parameters target The target object. sources The source object(s). var obj = { a: 1 }; var copy = Object.assign({}, obj); console.log(copy); // { a: 1 } Object.isSealed() method determines if an object is sealed. Syntax Object.isSealed(obj) Parameters obj The object which should be checked. var empty = {}; Object.isSealed(empty); // === false // If you make an empty object non-extensible, // it is vacuously sealed. Object.preventExtensions(empty); Object.isSealed(empty); // === true