-
Notifications
You must be signed in to change notification settings - Fork 1
/
object.js
26 lines (22 loc) · 911 Bytes
/
object.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
var obj = {
name: "nobir", //name holo properties(key bola jete pare) and 'nobir' holo value
}; //literal method for object creation
console.log(obj.name); //array hole [] use kora lagto, object ai jonno . use korbe, very easy. ei system ta ke bole dot notation
//tahole ekta value dukhate ki korbe??
// Constructor method for object creation
var obj1 = Object();
obj1.x = 10;
var obj2 = new Object();
obj2.y = 20;
// we can also use array notation
console.log(obj["name"]);
obj.age = "23";
console.log(obj);
// whern we use object notation
var x = 'name';
console.log(obj.x);//undifine,cause there is no x properties in obj;
console.log(obj[x]);//here x means 'name', though array notation all property with string. that's is the logic
//add a property by array notation
var dh = 'weight';
obj[dh] = 52;//variable use korte chaile dot notation use na kore array notaion use kora lagbe
console.log(obj);