Javascript

来源:互联网 发布:java使用redis统计 编辑:程序博客网 时间:2024/06/05 07:32

eval

含义:eval这个函数可以计算某个字符串,并执行其中的js代码。

例:

eval("x=10;y=20;document.write(x*y)");        document.write(eval("2+2"));        var x=10;        document.write(eval(x+17));        eval("alert('Hello world')");

在上面的代码运行后会打印 200   4   27



this

含义 : this代表函数运行时,自动生成的一个内部对象,只能在函数内部使用。

function test(){        this.x = 1;        alert(this.x);    }    test(); //1

var x = 1;    function test(){        this.x = 0;    }    test();    alert(x);  //0


function  test(){        alert(this.x);    }    var o ={};    o.x = 1;    o.m = test;    o.m();  //1




0 0
原创粉丝点击