日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

js函数基础知识

發布時間:2025/3/20 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 js函数基础知识 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

函數是對象的一種,函數名是對象的指針

函數作為參數傳遞

var box=function(a,b) {return a(b); }function a(b){return b+10; }alert(box(a,3));

?arguments.callee調用自身

function box(num){if(num<=1){return 1;}else{return num*arguments.callee(num-1);} }document.write(box(10));

this表示函數所處的作用域對象,如果在對象里面,就表示這個對象

全局下,this表示window

var box={name:"田偉",func:function(){return this.name;} }document.write(box.func());//田偉

函數的原型對象prototype 有2個方法call(),replay();

function box(a,b){return a+b; } function sum(c,d){return box.apply(this,[c,d]);
  //return box.apply(this,arguments); } document.write(sum(
3,4));
//冒充box,this表示box在window下面 function box(a,b){return a+b; } function sum(c,d){return box.call(this,c,d); } document.write(sum(3,555));

call?? 對象冒充

var color="藍色"; var box={color:"紅色" }function showcolor() {return this.color; } document.write(showcolor.call(box));

?

轉載于:https://www.cnblogs.com/yestian/p/6500943.html

總結

以上是生活随笔為你收集整理的js函数基础知识的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。