jsÖÐÊôÐÔºÍÒªÁìÓÐʲôÇø±ð
javascript ÖÐÊôÐÔÓÃÓÚ´æ´¢Êý¾Ý£¬¶øÒªÁìÓÃÓÚÖ´ÐвÙ×÷¡£ÊôÐÔʹÓÃÔ²µãÓï·¨»á¼û£¬¶øÒªÁìʹÓÃÀ¨ºÅÓï·¨»á¼û¡£ÊôÐÔÊÇÖµ£¬¶øÒªÁìÊÇ¿ÉÖ´ÐдúÂë¿é¡£
JavaScript ÖÐÊôÐÔºÍÒªÁìµÄÇø±ð
ÊôÐÔºÍÒªÁìÊÇ JavaScript ÖÐÁ½ÖÖ²î±ðµÄ³ÉÔ±¡£
ÊôÐÔ
ÊôÐÔÊÇ´æ´¢Êý¾ÝµÄ±äÁ¿¡£
ÔÚ JavaScript ÖУ¬ÊôÐÔÓÃÔ²µãÓï·¨ (.) »á¼û¡£
ÊôÐÔ¿ÉÒÔÊÇ»ù±¾ÀàÐÍ£¨ÀýÈç×Ö·û´®¡¢Êý×Ö¡¢²¼¶ûÖµ£©»òÖØ´óÀàÐÍ£¨ÀýÈçÊý×é¡¢¹¤¾ß£©¡£
ÀýÈ磺
const person = { name: "John Doe", age: 30 }; console.log(person.name); // "John Doe"
µÇ¼ºó¸´ÖÆ
ÒªÁì
ÒªÁìÊÇÓ빤¾ß¹ØÁªµÄº¯Êý¡£
ÔÚ JavaScript ÖУ¬ÒªÁìÓÃÀ¨ºÅÓï·¨ (()) »á¼û¡£
ÒªÁì¿ÉÒÔÖ´ÐвÙ×÷¡¢·µ»ØÖµ»òÐ޸Ť¾ß×ÔÉí¡£
ÀýÈ磺
const person = { name: "John Doe", sayHello() { console.log("Hello, world!"); } }; person.sayHello(); // Êä³ö "Hello, world!"
µÇ¼ºó¸´ÖÆ
Òªº¦Çø±ð
ÓÃ;£ºÊôÐÔÓÃÓÚ´æ´¢Êý¾Ý£¬¶øÒªÁìÓÃÓÚÖ´ÐвÙ×÷¡£
Óï·¨£ºÊôÐÔʹÓÃÔ²µãÓï·¨£¬¶øÒªÁìʹÓÃÀ¨ºÅÓï·¨»á¼û¡£
Ö´ÐУºÊôÐÔÊÇÖµ£¬¶øÒªÁìÊÇ¿ÉÖ´ÐдúÂë¿é¡£
Ð޸ģºÊôÐÔ¿ÉÒÔÐ޸ģ¬¶øÒªÁìͨ³£²»»áÐ޸Ť¾ß×ÔÉí¡£
ÒÔÉϾÍÊÇjsÖÐÊôÐÔºÍÒªÁìÓÐʲôÇø±ðµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡