Answers for "how to define an object in javascript"

30

javascript object

var	person = {
	first_name : "Marty",
  	last_name : "Mcfly",
	born : 1968,
	died : 1933,
    lovers: ["Jennifer Parker","Baines McFly"]
};
Posted by: Guest on June-27-2019
10

objects in javascript

let object = {
  'key1': 'value1',
  'key2': 'value2',
  'keyn': 'valuen',
};
console.log(object);
Posted by: Guest on June-19-2020
6

object object javascript

person = {
    'name':'john smith'
    'age':41
};

console.log(person);
//this will return [object Object]
//use
console.log(JSON.stringify(person));
//instead
Posted by: Guest on April-20-2020
2

objects in javascript

let car = {
  engineNumber: 1234
  brand: 'BMW',
  break: function (){}
}
Posted by: Guest on December-03-2020
1

make an object javascript

class ObjectLayout {
	constructor() {
    	this.firstName = "Larry"; //property
    }
  
  	sayHi() { // Method
    	return `Hello from ${this.firstName}`;
    }
}

const object = new ObjectLayout();
// object.firstName is Larry;
// object.sayHi() gives "Hello from Larry"
Posted by: Guest on November-03-2020
0

how to define an object in javascript

//object constructor with a method

function person(name,age){
	this.name=name;
    this.age=age;
    this.setName= function(name){
    	this.mame=name;
        }
  }
  
  const p1 = new person();
  p1.setName("John");
Posted by: Guest on August-12-2021

Code answers related to "how to define an object in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language