Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does blank braces indicate in javascript?

Tags:

javascript

What does {} indicate in javascript? For example

 var txt={};

{} means what?

like image 662
user7282 Avatar asked Nov 29 '22 01:11

user7282


1 Answers

It means an empty object. txt is declared as a new object in javascript with no properties. If you wanted to add properties you could use this:

var txt = { prop1: 'value 1', prop2: 'value 2' };

and then you can retrieve the values using txt.prop1 and txt.prop2.

like image 113
Darin Dimitrov Avatar answered Dec 15 '22 20:12

Darin Dimitrov