javascript鍩虹鐭ヨ瘑 瀵硅薄

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript鍩虹鐭ヨ瘑 瀵硅薄相关的知识,希望对你有一定的参考价值。

鏍囩锛?a href='http://www.mamicode.com/so/1/%e6%b5%8f%e8%a7%88%e5%99%a8' title='娴忚鍣?>娴忚鍣?/a>   null   false   name   鍙橀噺   ...   鏈嬪弸   class   

瀵硅薄

JavaScript鐨勫璞℃槸涓€绉嶆棤搴忕殑闆嗗悎鏁版嵁绫诲瀷锛屽畠鐢辫嫢骞查敭鍊煎缁勬垚銆?/p>

JavaScript鐨勫璞$敤浜庢弿杩扮幇瀹炰笘鐣屼腑鐨勬煇涓璞°€備緥濡傦紝涓轰簡鎻忚堪鈥滃皬鏄庘€濊繖涓窐姘旂殑灏忔湅鍙嬶紝鎴戜滑鍙互鐢ㄨ嫢骞查敭鍊煎鏉ユ弿杩颁粬锛?/p>

var xiaoming = {
    name: 鈥樺皬鏄庘€?span style="color: #000000">,
    birth: 1990,
    school: 鈥楴o.1 Middle School鈥?span style="color: #000000">,
    height: 1.70,
    weight: 65,
    score: null
};

JavaScript鐢ㄤ竴涓?code>{...}琛ㄧず涓€涓璞★紝閿€煎浠?code>xxx: xxx褰㈠紡鐢虫槑锛岀敤,闅斿紑銆?span style="color: #ff0000">娉ㄦ剰锛屾渶鍚庝竴涓敭鍊煎涓嶉渶瑕佸湪鏈熬鍔?code>,锛?/span>濡傛灉鍔犱簡锛屾湁鐨勬祻瑙堝櫒锛堝浣庣増鏈殑IE锛夊皢鎶ラ敊銆?/p>

涓婅堪瀵硅薄鐢虫槑浜嗕竴涓?code>name灞炴€э紝鍊兼槸鈥樺皬鏄庘€?/code>锛?code>birth灞炴€э紝鍊兼槸1990锛屼互鍙婂叾浠栦竴浜涘睘鎬с€傛渶鍚庯紝鎶婅繖涓璞¤祴鍊肩粰鍙橀噺xiaoming鍚庯紝灏卞彲浠ラ€氳繃鍙橀噺xiaoming鏉ヨ幏鍙栧皬鏄庣殑灞炴€т簡锛?/p>

xiaoming.name; // 鈥樺皬鏄庘€?/span>
xiaoming.birth; // 1990

璁块棶灞炴€ф槸閫氳繃.鎿嶄綔绗﹀畬鎴愮殑锛屼絾杩欒姹傚睘鎬у悕蹇呴』鏄竴涓湁鏁堢殑鍙橀噺鍚嶃€?span style="color: #ff0000">濡傛灉灞炴€у悕鍖呭惈鐗规畩瀛楃锛屽氨蹇呴』鐢?code>鈥樷€?/code>鎷捣鏉?/span>锛?/p>

var xiaohong = {
    name: 鈥樺皬绾⑩€?span style="color: #000000">,
    鈥榤iddle-school鈥? 鈥楴o.1 Middle School鈥?span style="color: #000000">
};

xiaohong鐨勫睘鎬у悕middle-school涓嶆槸涓€涓湁鏁堢殑鍙橀噺锛屽氨闇€瑕佺敤鈥樷€?/code>鎷捣鏉ャ€傝闂繖涓睘鎬т篃鏃犳硶浣跨敤.鎿嶄綔绗︼紝蹇呴』鐢?code>[鈥榵xx鈥榏鏉ヨ闂細

xiaohong[鈥榤iddle-school鈥榏; // 鈥楴o.1 Middle School鈥?/span>
xiaohong[鈥榥ame鈥榏; // 鈥樺皬绾⑩€?/span>
xiaohong.name; // 鈥樺皬绾⑩€?/span>

涔熷彲浠ョ敤xiaohong[鈥榥ame鈥榏鏉ヨ闂?code>xiaohong鐨?code>name灞炴€э紝涓嶈繃xiaohong.name鐨勫啓娉曟洿绠€娲併€?/p>

鎴戜滑鍦ㄧ紪鍐橨avaScript浠g爜鐨勬椂鍊欙紝灞炴€у悕灏介噺浣跨敤鏍囧噯鐨勫彉閲忓悕锛岃繖鏍峰氨鍙互鐩存帴閫氳繃object.prop鐨勫舰寮忚闂竴涓睘鎬т簡銆?/p>

瀹為檯涓奐avaScript瀵硅薄鐨勬墍鏈夊睘鎬ч兘鏄瓧绗︿覆锛屼笉杩囧睘鎬у搴旂殑鍊煎彲浠ユ槸浠绘剰鏁版嵁绫诲瀷銆?/span>

濡傛灉璁块棶涓€涓笉瀛樺湪鐨勫睘鎬т細杩斿洖浠€涔堝憿锛烰avaScript瑙勫畾锛岃闂笉瀛樺湪鐨勫睘鎬т笉鎶ラ敊锛岃€屾槸杩斿洖undefined

var xiaoming = {
    name: 鈥樺皬鏄庘€?span style="color: #000000">
};
xiaoming.age; // undefined

鐢变簬javascript鐨勫璞℃槸鍔ㄦ€佺被鍨嬶紝浣犲彲浠ヨ嚜鐢卞湴缁欎竴涓璞℃坊鍔犳垨鍒犻櫎灞炴€э細

var xiaoming = {
    name: 鈥樺皬鏄庘€?span style="color: #000000">
};
xiaoming.age; // undefined
xiaoming.age = 18; // 鏂板涓€涓猘ge灞炴€?/span>
xiaoming.age; // 18
delete xiaoming.age; // 鍒犻櫎age灞炴€?/span>
xiaoming.age; // undefined
delete xiaoming[鈥榥ame鈥榏; // 鍒犻櫎name灞炴€?/span>
xiaoming.name; // undefined
delete xiaoming.school; // 鍒犻櫎涓€涓笉瀛樺湪鐨剆chool灞炴€т篃涓嶄細鎶ラ敊

濡傛灉鎴戜滑瑕佹娴?code>xiaoming鏄惁鎷ユ湁鏌愪竴灞炴€э紝鍙互鐢?code>in鎿嶄綔绗︼細

var xiaoming = {
    name: 鈥樺皬鏄庘€?span style="color: #000000">,
    birth: 1990,
    school: 鈥楴o.1 Middle School鈥?span style="color: #000000">,
    height: 1.70,
    weight: 65,
    score: null
};
鈥榥ame鈥?in xiaoming; // true
鈥榞rade鈥?in xiaoming; // false

涓嶈繃瑕佸皬蹇冿紝濡傛灉in鍒ゆ柇涓€涓睘鎬у瓨鍦紝杩欎釜灞炴€т笉涓€瀹氭槸xiaoming鐨勶紝瀹冨彲鑳芥槸xiaoming缁ф壙寰楀埌鐨勶細

鈥榯oString鈥?in xiaoming; // true

鍥犱负toString瀹氫箟鍦?code>object瀵硅薄涓紝鑰屾墍鏈夊璞℃渶缁堥兘浼氬湪鍘熷瀷閾句笂鎸囧悜object锛屾墍浠?code>xiaoming涔熸嫢鏈?code>toString灞炴€с€?/p>

瑕佸垽鏂竴涓睘鎬ф槸鍚︽槸xiaoming鑷韩鎷ユ湁鐨勶紝鑰屼笉鏄户鎵垮緱鍒扮殑锛屽彲浠ョ敤hasOwnProperty()鏂规硶锛?/p>

var xiaoming = {
    name: 鈥樺皬鏄庘€?span style="color: #000000">
};
xiaoming.hasOwnProperty(鈥榥ame鈥?; // true
xiaoming.hasOwnProperty(鈥榯oString鈥?; // false

 

以上是关于javascript鍩虹鐭ヨ瘑 瀵硅薄的主要内容,如果未能解决你的问题,请参考以下文章

骞跺彂鐩稿叧闂浠ュ強java鍩虹鐭ヨ瘑

Linux绯荤粺鍩虹鐭ヨ瘑鐩綍銆佸厓鏁版嵁銆佽蒋纭摼鎺ャ€佹枃浠剁鐞嗗懡浠ゃ€乿im鏌ユ壘鏇挎崲銆乿imtab缂╄繘

銆愰潰璇曠瘒銆慔TML銆丆SS闈㈣瘯鐭ヨ瘑鐐归泦閿︼紝涓€鏂囧氨澶熶簡

Spring瀹瑰櫒绠$悊瀵硅薄鍜宯ew瀵硅薄

绫诲拰瀵硅薄