Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

ways of defining object js

1) Object Literal
	const obj = {
    	name: "Ram",
      	age: "20"
    }
2) Constructor Function or ES6- Class
   const a = new Person("Ram", "25") //given Person is an existing function or class
3) Object.create method
	const ram = Object.create(Person); //given person is an existing object
Source by htmlcheatsheet.com #
 
PREVIOUS NEXT
Tagged: #ways #defining #object #js
ADD COMMENT
Topic
Name
8+9 =