白凉粉是什么东西| 牛肉和什么相克| 授记是什么意思| reebok是什么牌子| 咽拭子是检查什么的| 皮肤病用什么药膏好| 日落西山是什么生肖| 梦见手机丢了又找到了是什么意思| 眼压高用什么药| 7月1日什么节日| 葫芦五行属什么| 食蚁兽是什么动物| 吃什么化痰| 相宜的意思是什么| 尿失禁是什么意思| 90年属什么| 阴茎长什么样| 放浪形骸是什么意思| 卤蛋吃多了有什么危害| 西瓜什么时候成熟| 晚秋是什么意思| 阴虚火旺吃什么中成药好| 女人下面有异味是什么原因| 大同有什么好玩的地方| 经由是什么意思| 缺铁性贫血严重会导致什么后果| 总是口腔溃疡是什么原因| 陋习什么意思| 芒果不能和什么食物一起吃| 虎口长痣代表什么| 等闲识得东风面下一句是什么| 腹黑是什么意思| 希五行属什么| 败血症吃什么药| 青蛙像什么| 做了胃镜多久可以吃东西吃些什么| 均可是什么意思| 感冒流鼻涕咳嗽吃什么药好| 来大姨妈吃什么对身体好| 兔子可以吃什么蔬菜| 什么蔬菜是温性的| 哺乳期发烧吃什么药| 加油站为什么不能打电话| 子字属于五行属什么| 什么牌子的学习机好| 叼是什么意思| 心衰有什么症状| 什么散步| 脂肪肝有什么危害| 查宝宝五行八字缺什么| 9月26号是什么星座| 胎位 头位是什么意思| 梦见栽树是什么意思| 扁肉是什么| 子痫前期是什么意思| 华萨尼男装是什么档次| hla是什么意思| 自然什么意思| 高钙血症是什么意思| 吃什么生精养精最快| 二月初十是什么星座| 上热下寒吃什么中成药| 梦见小牛犊是什么预兆| 有机什么意思| leslie什么意思| 单男是什么意思| 肺上有结节是什么病| 腰突挂什么科| 杨桃是什么季节的水果| 男性吃什么可以壮阳| 部队政委是什么级别| 竹节棉是什么面料| 喝什么茶对肝脏好| 人中附近长痘痘什么原因| 肺部纤维化是什么意思| 吃什么对眼睛有好处| 书记处书记是什么级别| 9点到11点是什么经络| 普外科是什么科| 舌头热灼是什么原因| 猪头肉是什么意思| 88年属什么的生肖| 嘴唇麻木什么病兆| 阴吹是什么| 老人睡眠多是什么原因| 风调雨顺的下联是什么| 东北属于什么气候| 月经期间吃什么食物最好| 11楼五行属什么| 嗓子吞咽疼痛吃什么药| 胃病不能吃什么| 经常胃胀是什么原因| 肠胃性感冒吃什么药| 为什么手会发麻| 危如累卵是什么意思| 梦到抓了好多鱼是什么意思| 前列腺炎吃什么中成药| 尿蛋白阳性什么意思| 耳朵外面痒是什么原因| 伏天从什么时候开始| 嫩模是什么意思| doris什么意思| 为什么睡觉总是做梦| 大姨妈每个月提前来是什么原因| 补气血吃什么药效果好| 诸侯国是什么意思| 冠脉造影是什么意思| 中老年人喝什么奶粉好| 猪蹄炖什么好吃| 五味子有什么功效| 总是困是什么原因| 水晶眼镜对眼睛有什么好处| 天肖是什么生肖| 挑食是什么意思| 清华校长什么级别| 吃深海鱼油有什么好处和坏处| 怀孕嗜睡什么时候开始| 黄连水有什么作用与功效| 结肠ca是什么意思| 痔疮应该挂什么科室| 的五行属什么| 无常是什么意思| 天珠是什么| eee是什么牌子的鞋| 2040年是什么年| 减肥晚上吃什么合适| 结甲是什么意思| 晚上睡觉阴部外面为什么会痒| 农历12月26日是什么星座| 金戈铁马是什么生肖| 什么叫飞机杯| 腰疼不能弯腰是什么原因引起的| 挖墙脚是什么意思| 柳州有什么大学| 吃什么减肥瘦肚子| 睾丸是什么形状的| 疣是什么病毒| 2月1号什么星座| 项链折了意味着什么| 1963年的兔是什么命| 包是什么结构| 属蛇的贵人是什么属相| 吃什么可以提高新陈代谢| 医院脱毛挂什么科| 脘腹胀满是什么意思| 欧阳修是什么居士| 什么首什么胸| 躺平是什么意思| 腐竹炒什么好吃| 马是什么牌子的车| 2月12号是什么星座| 胸推是什么| 什么人容易得小脑萎缩| 人的牙齿为什么不能再生| 脑供血不足食补吃什么| 抗原和抗体有什么区别| 心跳的快是什么原因| 眼睛红痒用什么眼药水| 7什么意思| 阴道瘙痒用什么药| 肠炎能吃什么食物| 男生爱出汗是什么原因| 什么含维生素d| 痰栓是什么意思| 洗面奶和洁面乳有什么区别| 什么菜补血| 什么菜煮不熟| 肝在人体什么位置| 胃胀气是什么症状| 新房送什么礼物好| 矫正视力是什么意思| 231是什么意思| 头晕流鼻血是什么原因| 琛读什么| 胃下垂有什么症状表现| 瑜五行属什么| 头发干枯毛躁是什么原因| 手筋痛是什么原因| 什么人不能吃海参| 6月份能种什么菜| 酒酿蛋什么时候吃效果最好| 长卿是什么意思| 天时地利人和什么意思| 宫颈息肉有什么症状| 辣皮子是什么| 乙肝e抗原阳性是什么意思| 毛囊炎是什么| 骨挫伤是什么意思| 皮癣用什么药膏| 怀孕肚子疼是什么原因| fossil是什么牌子| p波增宽是什么意思| 样本是什么意思| 什么夫妻百事哀| 杀青原指什么| 孕吐是什么原因造成的| 滴水观音叶子发黄是什么原因| 吃苦荞有什么好处| 海子为什么自杀| 看胆囊挂什么科| 喝酒之前吃什么保护胃| 心衰挂什么科| 独在异乡为异客的异是什么意思| 淋巴是什么东西| 舅舅的孙子叫我什么| 宝宝低烧吃什么药| dm是什么意思| 80岁是什么之年| 病毒感染咳嗽吃什么药效果好| 颈椎病有些什么症状| 无氧运动是什么| 灰绿色是什么颜色| 溜冰是什么意思| 热感冒流鼻涕吃什么药| 腿毛长得快是什么原因| 煦字五行属什么| 老是拉肚子什么原因| 壬水代表什么| 右下眼皮跳是什么原因| 相安无事是什么意思| 什么牌子的洗衣机最好| 不字五行属什么| pr过高是什么意思| 不尽人意是什么意思| 四肢发达是什么生肖| 早博是什么| 什么是辣木籽| 六月份什么星座| 鼻子痒是什么原因| 老是打嗝是什么病的征兆| 独立户口需要什么条件办理| 乳房看什么科| 梦见捡到钱是什么意思| 低聚异麦芽糖是什么| 坐月子送什么礼物好| 睡觉中途总醒什么原因| 六月初三是什么日子| 男人更年期在什么年龄| 属鸡适合佩戴什么饰品| 营养过剩是什么意思| 高就是什么意思| 血压高吃什么| 腿抖是什么病的预兆| 仪态什么什么| 什么叫息肉| 三净肉指什么| 94是什么意思| 肝郁脾虚是什么意思| bug是什么意思中文翻译| 过敏性鼻炎吃什么药好| 早上喝一杯温开水有什么好处| 为什么人会死| 身上很痒是什么原因| 口腔医学和口腔医学技术有什么区别| 徒手是什么意思| 新股配号数量是什么意思| 凡人修仙传什么时候写的| 碳酸钙d3颗粒什么时候吃最好| 缓释片是什么意思| 三十如狼四十如虎什么意思| 冒菜为什么叫冒菜| 结婚28年是什么婚| 什么是溶血症| 没有精液是什么原因| 百度

武汉恒隆广场购物中心及地下室首块大底板完成浇筑

百度 搞生搬硬套之举、行“拿来主义”之策,究其实质还是工作态度不端正、思想意识跑错道,终究是“作风病”使然。

Summary: in this tutorial, you will learn about JavaScript objects and how to manipulate object properties effectively.

Introduction to the JavaScript objects

In JavaScript, an object is an unordered collection of key-value pairs. Each key-value pair is called a property.

The key of a property can be a string. The value of a property can be any value, e.g., a string, a number, an array, and even a function.

JavaScript provides you with many ways to create an object. The most commonly used one is to use the object literal notation.

The following example creates an empty object using the object literal notation:

let empty = {};Code language: JavaScript (javascript)

To create an object with properties, you use the key : value within the curly braces. For example, the following creates a new person object:

let person = {
    firstName: 'John',
    lastName: 'Doe'
};Code language: JavaScript (javascript)

The person object has two properties firstName and lastName with the corresponding values 'John' and 'Doe'.

When an object has multiple properties, you use a comma (,) to separate them like the above example.

Accessing properties

To access a property of an object, you use one of two notations: the dot notation and array-like notation.

1) The dot notation (.)

The following illustrates how to use the dot notation to access a property of an object:

objectName.propertyNameCode language: CSS (css)

For example, to access the firstName property of the person object, you use the following expression:

person.firstNameCode language: CSS (css)

This example creates a person object and shows the first name and last name to the console:

let person = {
    firstName: 'John',
    lastName: 'Doe'
};

console.log(person.firstName);
console.log(person.lastName);Code language: JavaScript (javascript)

2) Array-like notation ( [])

The following illustrates how to access the value of an object’s property via the array-like notation:

objectName['propertyName']Code language: CSS (css)

For example:

let person = {
    firstName: 'John',
    lastName: 'Doe'
};

console.log(person['firstName']);
console.log(person['lastName']);Code language: JavaScript (javascript)

When a property name contains spaces, you need to place it inside quotes. For example, the following address object has the 'building no' as a property:

let address = {
    'building no': 3960,
    street: 'North 1st street',
    state: 'CA',
    country: 'USA'
};
Code language: JavaScript (javascript)

To access the 'building no' property, you need to use the array-like notation:

address['building no'];Code language: CSS (css)

If you use the dot notation, you’ll get an error:

address.'building no';Code language: JavaScript (javascript)

Error:

SyntaxError: Unexpected stringCode language: JavaScript (javascript)

Note that it is not a good practice to use spaces in the property names of an object.

Reading from a property that does not exist will result in an undefined. For example:

console.log(address.district);Code language: CSS (css)

Output:

undefinedCode language: JavaScript (javascript)

Modifying the value of a property

To change the value of a property, you use the assignment operator (=). For example:

let person = {
    firstName: 'John',
    lastName: 'Doe'
};

person.firstName = 'Jane';

console.log(person);Code language: JavaScript (javascript)

Output:

{ firstName: 'Jane', lastName: 'Doe' }Code language: CSS (css)

In this example, we changed the value of the firstName property of the person object from 'John' to 'Jane'.

Adding a new property to an object

Unlike objects in other programming languages such as Java and C#, you can add a property to an object after object creation.

The following statement adds the age property to the person object and assigns 25 to it:

person.age = 25;

Deleting a property of an object

To delete a property of an object, you use the delete operator:

delete objectName.propertyName;Code language: JavaScript (javascript)

The following example removes the age property from the person object:

delete person.age;Code language: JavaScript (javascript)

If you attempt to reaccess the age property, you’ll get an undefined value.

Checking if a property exists

To check if a property exists in an object, you use the in operator:

propertyName in objectName

The in operator returns true if the propertyName exists in the objectName.

The following example creates an employee object and uses the in operator to check if the ssn and employeeId properties exist in the object:

let employee = {
    firstName: 'Peter',
    lastName: 'Doe',
    employeeId: 1
};

console.log('ssn' in employee);
console.log('employeeId' in employee);Code language: JavaScript (javascript)

Output:

false
trueCode language: JavaScript (javascript)

Quiz

Summary

  • An object is a collection of key-value pairs.
  • Use the dot notation (.) or array-like notation ([]) to access the property of an object.
  • Use the delete operator to remove a property from an object.
  • Use the in operator to check if a property exists in an object.
Was this tutorial helpful ?
什么是阴阳人 mic是什么单位 口苦口臭挂什么科 电气火灾用什么灭火器 梦见好多蛇是什么意思
什么蔬菜降血压效果最好 斯里兰卡属于什么国家 肩周炎贴什么膏药效果最好 吴佳尼为什么嫁马景涛 肝藏血是什么意思
没是什么意思 月令是什么意思 海参什么样的好 总手是什么意思 碧文圆顶是什么意思
黑马是什么意思 梦到认识的人死了是什么意思 abr是什么意思 智障是什么意思 名列前茅的茅是什么意思
肝有问题会出现什么症状hcv8jop1ns5r.cn 毛周角化症用什么药膏hcv9jop5ns0r.cn 我丢什么意思hcv8jop1ns9r.cn 蕞是什么意思bjcbxg.com 什么血型不招蚊子hcv9jop4ns8r.cn
长期口腔溃疡挂什么科hcv8jop0ns2r.cn 长期喝饮料对身体有什么危害hcv8jop6ns7r.cn 十月7号是什么星座hcv8jop7ns0r.cn 下嘴唇发紫是什么原因hcv8jop6ns9r.cn 白领是什么职业hcv8jop3ns4r.cn
客套是什么意思hcv7jop6ns9r.cn 茄子与什么食物相克hcv7jop7ns3r.cn 石加乏念什么hcv7jop5ns4r.cn ricu病房是什么意思clwhiglsz.com 990是什么意思hcv9jop5ns6r.cn
5月22日什么星座hcv7jop5ns0r.cn 古代医院叫什么hcv9jop7ns3r.cn 什么是君子520myf.com 什么叫扁平疣hcv8jop3ns3r.cn 车万是什么意思dajiketang.com
百度