<!DOCTYPEhtml><html><head><metacharset="utf-8"><title>梁辰兴实例</title></head><head><script>functionsetCookie(cname,cvalue,exdays){var d =newDate();
d.setTime(d.getTime()+(exdays*24*60*60*1000));var expires ="expires="+d.toGMTString();
document.cookie = cname+"="+cvalue+"; "+expires;}functiongetCookie(cname){var name = cname +"=";var ca = document.cookie.split(';');for(var i=0; i<ca.length; i++){var c = ca[i].trim();if(c.indexOf(name)==0)return c.substring(name.length,c.length);}return"";}functioncheckCookie(){var user=getCookie("username");if(user!=""){alert("Welcome again "+ user);}else{
user =prompt("Please enter your name:","");if(user!=""&& user!=null){setCookie("username",user,30);}}}</script></head><bodyonload="checkCookie()"></body></html>
<!DOCTYPEhtml><html><head><metacharset="utf-8"><title>梁辰兴实例</title></head><body><script>
person={firstname:"John",lastname:"Doe",age:50,eyecolor:"blue"}
document.write(person.firstname +" is "+ person.age +" years old.");</script></body></html>
运行效果
创建用于对象的模板
源码
<!DOCTYPEhtml><html><head><metacharset="utf-8"><title>梁辰兴实例</title></head><body><script>functionperson(firstname,lastname,age,eyecolor){this.firstname=firstname;this.lastname=lastname;this.age=age;this.eyecolor=eyecolor;}
myFather=newperson("John","Doe",50,"blue");
document.write(myFather.firstname +" is "+ myFather.age +" years old.");</script></body></html>
值函数近似Value Function ApproximationMotivating examples: curve fittingAlgorithm for state value estimationObjective functionOptimization algorithmsSelection of function approximatorsIllustrative examplesSummary of the storyTheoretical analysisSarsa with …