JavaScript ¼Ì³Ð
myhere
// ѧϰҪÏ뿽±´ÄÇô¿ì¾ÍºÃÁË
//
// JavaScript µÄ¼Ì³ÐÊÇ»ùÓÚ prototype µÄ£¬Ã¿¸ö¶ÔÏóµÄ prototype ÊDZ£´æÔÚ¶ÔÏóµÄ __proto__ ÊôÐÔÖеģ¬Õâ¸öÊôÐÔÊÇÄÚ²¿(internal)µÄÊôÐÔ( ¹ßÀýÊÇÄÚ²¿µÄ»òÕßÒþ²ØµÄÊôÐÔÒÔ _ ¿ªÍ·)
// A prototype-based language has the notion of a prototypical object, an object used as a template from which to get the initial properties for a new object.
//
/**
* Property lookup in Javascript looks within an object's own properties and,
* if the property name is not found, it looks within the special object property __proto__.
* This continues recursively; the process is called "lookup in the prototype chain".
* The special property __proto__ is set when an object is constructed;
* it is set to the value of the constructor's prototype property.
* So the expression new Foo() creates an object with __proto__ == Foo.prototype.
* Consequently, changes to the properties of Foo.prototype alters the property lookup for all objects that were created by new Foo().
*/
// ¸ø¶ÔÏóµÄÔÐÍÔö¼Ó³ÉÔ±»áÁ¢¼´ÔڸöÔÏóÖпɼû
function Base(){
this.name = 'myhere';
}
function Sub(){
this.age = 23;
}
Sub.prototype = new Base(); // ¸øÔÐ͸³ÖµÎªÒ»¸ö==¶ÔÏó==¡£
var me = new Sub();
// ´´½¨¶ÔÏóºó¸øÔÐÍÔö¼Ó sex ÊôÐÔ£¬¸ÃÊôÐÔÁ¢¼´ÔÚ¶ÔÏóÖпɼû
Base.prototype.sex = 'male';
var str = '';
str += me.name + me.age + me.sex;
document.write( str); // myhere23male
/**
* ˵Ã÷£º
* ¶ÔÓÚÕâÖּ̳У¬ÔÚÆµ·±ÐÞ¸ÄÔÐ͵ÄÇé¿öϾͱäµÃ»ìÂÒÁË
*/
//
/**
* ÁíÒ»Öּ̳з½·¨
*/
function Base(){
this.name = 'myhere';
}
// ²¢Ã»Óн« Sub µÄÔÐ͸³ÖµÎª Base£¬Ö»ÊÇÔÚ Sub Öе÷Óà Base º¯Êý
function Sub(){
this.age = 23;
Base.call( this); // Ö»Êǽ«Ò»²¿·Ö³õʼ»¯½»¸ø Base º¯Êý£¬²¢Ã»ÓвÙ×÷ prototype
}
var me = new Sub();
Base.prototype.sex = 'male'; // ÐÞ¸Ä Base ²»»áÓ°Ïì Sub µÄ¶ÔÏó£¬ÒòΪ Base ²¢²»ÊÇ Sub µÄÔÐÍ
// Èç¹û½«Õâ¸öÔö¼Ó sex µÄÓï¾ä·Åµ½ Sub ¶¨Òåǰ£¬ÔÚ me ÖÐÒ²µÃ²»µ½ sex ÊôÐÔ£¬
// ÒòΪ Base.call() Ö»Êǵ÷Óà Base º¯Êý¶øÒÑ
var str = '';
str += me.name + m
Ïà¹ØÎĵµ£º
¾³£ÔÚie6ϳöÏÖjavascriptÒ³ÃæÌø×ªºÍ±íµ¥Ìá½»ÎÊÌ⣬ie6ÏÂʵÏÖjavascriptÒ³ÃæÌø×ªºÍ±íµ¥Ìá½»ÐèÒª½øÐÐÌØ±ð´¦Àí£¬ÐèҪʹÓÃsetTimeout()º¯ÊýÑÓ³ÙʵÏÖ¡£
1£¬¼æÈݸ÷ä¯ÀÀÆ÷µÄJavascriptÒ³ÃæÌø×ª
setTimeout(function(){
window.location.href = url;
},0);
2£¬¼æÈݸ÷ä¯ÀÀÆ÷µÄJavascript±íµ¥Ìá½»
setTimeout(function ......
function f_MobilCheck(as_SourceString)
{
if(as_SourceString.match(/^13[0-9]{9}$/g)) return true; //ÊÖ»úºÅΪ13¿ªÍ·µÄ11λÊý×Ö
else if(as_SourceString.match(/^[0]{1}[0-9]{2,3}[2-8]{1}[0-9]{5,7}$/g)) return true;¡¡¡¡//СÁéͨΪ0¿ªÍ·µÄ3-4λµÄÇøºÅ£«²»ÒÔ1ºÍ9¿ªÍ·µÄ6£8λÊý×Ö
retur ......
µÚÈýÕÂ ¶ÔÏó»ù´¡
ÔÚjavaScriptÖУ¬¶ÔÏóÊÇÎÞÌØ¶¨Ë³ÐòµÄÖµµÄÊý×é¡£
Ò»¡¢¶ÔÏóµÄÀàÐÍ
·ÖΪ±¾µØ¶ÔÏó¡¢ÄÚÖöÔÏóºÍËÞÖ÷¶ÔÏóÈýÖÖ£¬ÆäÖÐÄÚÖöÔÏóÒ²ÊôÓÚ±¾µØ¶ÔÏó¡£
¶þ¡¢±¾µØ¶ÔÏó£º
1¡¢ArrayÀ࣬Êý×éÀà¡£
  ......
javascript¶ÔÏóÖ®——ÄÚÖöÔÏó“Math”
Math¶ÔÏóµÄһЩ·½·¨ÄÜʵÏÖÎÒÃǿα¾ÉϵÄijЩÊýѧ¼ÆË㣬±È½Ï³£Óõķ½·¨ÓÐÈçϼ¸¸ö£º
Ò»¡¢Math.min()ºÍMath.max()£¬·Ö±ð·µ»Ø²ÎÊýÖеÄ×îСºÍ×î´óÖµ
¡¡¡¡Àý£º
¡¡¡¡alert(Math.min(1,2,3))¡¡¡¡//Êä³ö “1”
¡¡¡¡alert(Math.max(1,2,3))¡¡¡¡//Êä³ö &ldq ......
²»Óò»ÖªµÀ,Ò»ÓòÅÖªµÀÕâÁ½ÕßÊDz»´óÒ»ÑùµÄ,ÏñÔÚjavaÖÐ,ÊÇÖ±½ÓʹÓà ,Èç str1.replace("$","*") °Ñ$ºÅ±ä³É*ºÅ
µ«ÔÚjavascript¾Í²»Ò»Ñù,ҪʵÏÖÉÏÃæµÄ¹¦ÄÜÊÇÕâÑùд: str.replace(/&/g,"*") ÆäÖеÄgÊDzÎÊý,˵Ã÷Òª½«È«²¿µÄ$¶¼±ä³É*
ÏÂÃæ°ÑjavascriptµÄÕ³ÌùÔÚÏÂÃæ:
¶¨ÒåºÍÓ÷¨
replace() ·½·¨ÓÃÓÚÔÚ×Ö·û´®ÖÐÓÃһЩ×Ö·ûÌ ......