JavaScript 学习笔记 一 动态性
//动态性是指,在一个 Javascript 对象中,要为一个属性赋值,我们不必事先创建一个字段,//只需要在使用的时候做赋值操作即可var obj = new Object();obj.name = "aa ";obj.sayHi = function(){return "Hi "+obj.name;}function say(){alert(obj.sayHi());}var objarr = new Array("cc", "aa");var objstr = new String("hello");// 类型的判function handle(msg){ alert(msg); say();}function handleMsg(msg,handle){ if(handle instanceof Function) handle(msg); else throw new Error("the 2nd argument should be a function");}handleMsg("hello aa",handle);handleMsg("hello aa"," cc");