Search

1/22/2007

Javascript Literals

  • Function Literals
    var squares = function(x){ return x*x; }
    var square = new Function("x", "return x*x;");

    Object Literals
    var point = new Object({x:2.3, y:-1.2});var point = {x:2.3, y:-1.2};
    var point = new Object({x:2.3, y:-1.2});

    Array Literals
    var a = [1.2, "Javascript", true, {x:1, y:3}];
    var a = new Array(1.2, "Javascript", true, {x:1, y:3});

沒有留言: