---
title: "可变参数"
author: "digilover"
date: "2012-04-29T09:10:16Z"
tags: []
categories: ["Web前端"]
slug: "untitled"
draft: false
lastmod: "2012-04-29T09:10:16Z"
id: 1503387
url: "https://digilover.iteye.com/blog/1503387"
---

&lt;script type="text/javascript"&gt;

     function testparams(){

      var params="";

      for(var i=0;i&lt;arguments.length;i++){

      params += " " + arguments\[i];

      }

      alert(params);

     }

     testparams("abc",123);

     testparams("abc",123,321);

  &lt;/script&gt;

arguments是每一个js函数的内置属性，代表的是实际传递给这个函数的参数

&lt;!--EndFragment--&gt;