length 속성을 가진 대상

1425 단어 length
1. window 설정 또는 창의 프레임 프레임 수를 반환합니다.
주요 브라우저는length 속성과 window를 지원합니다.frame.length 속성의 값은 같습니다.
<script type="text/javascript">
    alert(window.length);//"3"
    alert(window.frame.length);//"3"
</script>
<body>
   <iframe src="http://microsoft.com"></iframe>
   <iframe src="http://www.w3school.com.cn/index.html"></iframe>
   <iframe src="http://www.baidu.com"></iframe>
</body>

2. function 함수에서 원하는 매개 변수의 개수입니다.기본적으로 예상되는 매개 변수의 개수를 보기 위한 간편한 방법이 있습니다.

function testplus(i) {
  alert(i*i);
}
function sayHello() {
  alert("Hello!");
}
alert(testplus.length);	// ,  "1"
alert(sayHello.length);	// ,  "0"

3. array 는 배열의 요소 수를 설정하거나 반환합니다.

<script type="text/javascript">
function getElements()
  {
  var x=document.getElementsByTagName("input");// 
  alert(x.length);//"1"
  }
</script>
<input type="button" onclick="getElements()" />

4.string은 문자열의 길이를 계산합니다.

var txt="Hello World!";
alert(txt.length);//"12"

좋은 웹페이지 즐겨찾기