Read full article on the Infragistics blog
Here are some fun facts for you: JavaScript is not an object oriented language, but almost everything in JavaScript is an object. JavaScript does not have classes, and we can create an object from an object. A function can be used as a constructor, and returns a newly created object. Every object in JavaScript contains a second object called a prototype object.
If you’re coming from a .NET background, the sentences you just read probably don’t make any sense. But these are all true statements about JavaScript. And in this post we will focus on different ways to create objects in JavaScript
- Object as literal
- Creating an object using the new operator and constructors
- Creating an object using the Object.create() static method
Object creation as literal
The simplest way to create an object is by creating an object using the object literal. We can create a simple object as shown in the listing below:
Leave a Reply