<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script type="text/javascript">
// function test() {
// var name = "duyi";
// obj = "boj";
// console.log(delete obj); //true
// console.log(delete name); //false
// }
// test();
// function test(a,b) {
// console.log(a);
// c = 0;
// var c;
// a = 3;
// b = 2;
// console.log(b);
// function b () {}
// function d () {}
// }
// test(1);
// AO {
// a : 3
// b : 2
// d : function
// }
// GO{
// c : 0;
// }
// function a () {
// function b () {
// var b = 234;
// aa = 0;
// }
// var aa = 123;
// b();
// console.log(aa);
// var glob = 100;
// }
// a();
// function test(arg1,arg2) {
// console.log(arg1 , arg2); //html css
// // function arg1() {};
// arguments[0] = "duyi";
// arg2 = "web";
// console.log(arg1);//duyi
// console.log(arguments[1]);//web
// }
// test("html","css");
// var arr = [0,1,2];
// arr[9] = 10;
// console.log(arr.length);//10
// function test() {
// //當new時 var this = test.this;
// this.name = "duyi";
// return{
// name : "qaq"
// };
// //return this; this = {
// // name : "qaq"
// //}
// }
// var pp = new test();
// console.log(pp.name); //qaq pp.name = this.name;
// var list = [1+2,1*2,1/2];
// console.log(list);
// window.name = "qaq";
// var hero = {
// name: 'duy',
// qaq: function() {
// return this.name;
// }
// }
// var qaq1 = hero.qaq;
// console.log(qaq1.call(hero));
// console.log(hero.qaq());
// function a() {
// y = function() {
// x = 2;
// };
// return function() {
// var x = 3;
// y();
// console.log(this.x);
// }.apply(this, arguments);
// }
// a();
var n = "Welcome to duyi".indexOf("duyi",6);
//當傳入的數值不爲 0 , null ,undefined時輸出傳入的值
//當爲這些值時輸出默認值。。這就是企業開發||的用處
// function test(url, timeout, callback) {
// timeout = timeout || 2000;
// callback = callback || function(){};
// console.log(url,timeout,callback);
// }
// test1("/getmsg"); // getmsg 2000 fuction
// test1("/getmsg",5000);// getmsg 5000 fuction
// test1("/getmsg",5000,function(){});//getmsg 5000 fuction
// test1("/getmsg",0,null);
function addToList(item,list) {
return list.push(item);
}
var result = addToList("apple",["banana"]);
console.log(result);//2
//返回值爲2 因爲push() 方法可向數組的末尾添加一個或多個元素,
//並返回新的長度。
</script>
</body>
</html>
JavaScript小語法點總結——每日練習題
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.