Skip to content
This repository has been archived by the owner on Nov 23, 2024. It is now read-only.

Latest commit

 

History

History

extensions_to_object

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Extensions to Object

Shorthand

let foo = 'foo';
let bar = 'bar';

let foobar = { foo, bar };
console.log(foobar);

Methods

let foobar = {
	foo: function() {
		console.log('foo');
	},
	
	bar() {
		console.log('bar');
	},
}

foobar.foo();
foobar.bar();

Dynamic Property Names

let answer = 42;

let object = {
	['foo_' + answer]: 'foo',
	['bar_' + answer]: 'bar',
}

console.log(object);