JavaScript ¼Ì³ÐÏê½â4
ÔÚ±¾ÕÂÖУ¬ÎÒÃǽ«·ÖÎöDouglas Crockford¹ØÓÚJavaScript¼Ì³ÐµÄÒ»¸öʵÏÖ
CrockfordÊÇJavaScript¿ª·¢ÉçÇø×îÖªÃûµÄȨÍþ£¬ÊÇJSON
¡¢JSLint
¡¢JSMin
ºÍADSafe
Ö®¸¸£¬ÊÇ¡¶JavaScript: The Good Parts¡·µÄ×÷Õß¡£
ÏÖÔÚÊÇYahooµÄ×ÊÉîJavaScript¼Ü¹¹Ê¦£¬²ÎÓëYUIµÄÉè¼Æ¿ª·¢¡£ ÕâÀïÓÐһƪÎÄÕÂ
Ïêϸ½éÉÜÁËCrockfordµÄÉúƽºÍÖø×÷¡£
µ±È»CrockfordÒ²ÊÇÎÒµÈС±²³ç°ÝµÄ¶ÔÏó¡£
µ÷Ó÷½Ê½
Ê×ÏÈÈÃÎÒÃÇ¿´ÏÂʹÓÃCrockfordʽ¼Ì³ÐµÄµ÷Ó÷½Ê½£º
×¢Ò⣺´úÂëÖеÄmethod¡¢inherits¡¢uber¶¼ÊÇ×Ô¶¨ÒåµÄ¶ÔÏó£¬ÎÒÃÇ»áÔÚºóÃæµÄ´úÂë·ÖÎöÖÐÏê½â¡£
// ¶¨ÒåPersonÀà
function Person(name) {
this.name = name;
}
// ¶¨ÒåPersonµÄÔÐÍ·½·¨
Person.method("getName", function() {
return this.name;
});
// ¶¨ÒåEmployeeÀà
function Employee(name, employeeID) {
this.name = name;
this.employeeID = employeeID;
}
// Ö¸¶¨EmployeeÀà´ÓPersonÀà¼Ì³Ð
Employee.inherits(Person);
// ¶¨ÒåEmployeeµÄÔÐÍ·½·¨
Employee.method("getEmployeeID", function() {
return this.employeeID;
});
Employee.method("getName", function() {
// ×¢Ò⣬¿ÉÒÔÔÚ×ÓÀàÖе÷Óø¸ÀàµÄÔÐÍ·½·¨
return "Employee name: " + this.uber("getName");
});
// ʵÀý»¯×ÓÀà
var zhang = new Employee("ZhangSan", "1234");
console.log(zhang.getName()); // "Employee name: ZhangSan"
ÕâÀïÃæÓм¸´¦²»µÃ²»ÌáµÄÓ²ÉË£º
×ÓÀà´Ó¸¸Àà¼Ì³ÐµÄ´úÂë±ØÐëÔÚ×ÓÀàºÍ¸¸À඼¶¨ÒåºÃÖ®ºó½øÐУ¬²¢ÇÒ±ØÐëÔÚ×ÓÀàÔÐÍ·½·¨¶¨Òå֮ǰ½øÐС£
ËäÈ»×ÓÀà·½·¨ÌåÖпÉÒÔµ÷Óø¸ÀàµÄ·½·¨£¬µ«ÊÇ×ÓÀàµÄ¹¹Ô캯ÊýÎÞ·¨µ÷Óø¸ÀàµÄ¹¹Ô캯Êý¡£
´úÂëµÄÊéд²»¹»ÓÅÑÅ£¬±ÈÈçÔÐÍ·½·¨µÄ¶¨ÒåÒÔ¼°µ÷Óø¸ÀàµÄ·½·¨£¨²»Ö±¹Û£©¡£
µ±È»CrockfordµÄʵÏÖ»¹Ö§³Ö×ÓÀàÖеķ½·¨µ÷Óôø²ÎÊýµÄ¸¸Àà·½·¨£¬ÈçÏÂÀý×Ó£º
function Person(name) {
this.name = name;
}
Person.method("getName", function(prefix) {
return prefix + this.name;
});
function Employee(name, employeeID) {
this.name = name;
this.employeeID = employeeID
Ïà¹ØÎĵµ£º
Ç°Ìì×öµÄÒ³ÃæÊÇÒ»¸öiframeµ¯³ö´°¿Ú£¨ËµÃ÷һϣºÍ¬ÊÂÓÃjs½Å±¾¿ª·¢³öÀ´µÄ£©Àï´¥·¢Ò»¸ö<a>Á´½ÓµÄ°´Å¥¿ÉÔڸô°¿ÚÉϵ¯³öÒ»¸ödivÐü¸¡²ã¡£µ«ÊÇÿ´Îµã»÷£¬divÐü¸¡²ã¾Í×Ô¶¯Î»ÓÚIE´°¿ÚµÄ¶¥¶Ë£¬ÏÂÃæµÄiframe´°¿Ú°üº¬µÄÒ³Ãæ»á×Ô¶¯ÉÏÒÆ£¬Î»ÖôíÂÒÁË¡£
ͬÊÂ˵Ö÷ÒªÊ ......
<script language="JavaScript" type="text/JavaScript">
<!--
function displayScreenSize()
{
var bodyWidth ......
EclipseдjavascriptÊDZȽÏÍ´¿àµÄ,ÓÐÁËjsEclipseÕâ¸öÇ¿´óµÄjavascript±à¼²å¼þ¾Í·½±ã¶àÁË,Õâ¸ö²å¼þÖ§³Ö´úÂëÍê³É,´ó¸Ùä¯ÀÀ,´íÎ󱨸æ,´úÂë»»ÐеȵÈ.
°²×°jsEclipseºÜ·½±ã,ͨ¹ýHELP-Software Updates-Find and Install ÔÚURLÖмÈëhttp://www.interaktonline. ......
¼¸ºõÿ¸ö¿ª·¢ÈËÔ±¶¼ÓÐÃæÏò¶ÔÏóÓïÑÔ£¨±ÈÈçC++¡¢C#¡¢Java£©µÄ¿ª·¢¾Ñé¡£ ÔÚ´«Í³ÃæÏò¶ÔÏóµÄÓïÑÔÖУ¬ÓÐÁ½¸ö·Ç³£ÖØÒªµÄ¸ÅÄî - ÀàºÍʵÀý¡£
ÀඨÒåÁËÒ»ÀàÊÂÎ﹫¹²µÄÐÐΪºÍ·½·¨£»¶øʵÀýÔòÊÇÀàµÄÒ»¸ö¾ßÌåʵÏÖ¡£ ÎÒÃÇ»¹ÖªµÀ£¬ÃæÏò¶ÔÏó±à³ÌÓÐÈý¸öÖØÒªµÄ¸ÅÄî - ·â×°¡¢¼Ì³ÐºÍ¶à̬¡£
µ«ÊÇÔÚJavaScriptµÄÊÀ½çÖУ¬ËùÓеÄÕâÒ»ÇÐÌØ ......
ÕâÒ»ÕÂÎÒÃǽ«»áÖصã½éÉÜJavaScriptÖм¸¸öÖØÒªµÄÊôÐÔ£¨this¡¢constructor¡¢prototype£©£¬ ÕâЩÊôÐÔ¶ÔÓÚÎÒÃÇÀí½âÈçºÎʵÏÖJavaScriptÖеÄÀàºÍ¼Ì³ÐÆð×ÅÖÁ¹ØÖØÒªµÄ×÷Óá£
this
this±íʾµ±Ç°¶ÔÏó£¬Èç¹ûÔÚÈ«¾Ö×÷Ó÷¶Î§ÄÚʹÓÃthis£¬ÔòÖ¸´úµ±Ç°Ò³Ãæ¶ÔÏówindow£» Èç¹ûÔÚº¯ÊýÖÐʹÓÃthis£¬ÔòthisÖ¸´úʲôÊǸù¾ÝÔËÐÐʱ´Ëº¯ÊýÔÚʲ ......