# 표준 내장 객체의 확장

표준 내장 객체(Standard Built-in Object)는 자바스크립트가 기본적으로 가지고 있는 객체들을 의미한다. 프로그래밍이라는 것은 언어와 호스트 환경에서 제공하는 기능들을 통해서 새로운 소프트웨어를 만들어내는 것이기 때문에 내장 객체에 대한 이해는 프로그래밍의 기본이라고 할 수 있다.

ex) Object, Function, Array, String, Boolean, Number, Math, Date, RegExp

**배열의 확장**

```javascript
var arr = new Array('seoul', 'new york', 'ladarkh','pusan','Tsukuba');
function getRandomValueFromArray(arr) {
    var index = Math.floor(arr.length*Math.randon());//floor메소드는 버림 연산을 하여 정수를 리.
    return result;
 } 
 console.log(getRandomValueFromArray(arr));//배열의 원소가 랜덤으로 출력된다.
```

**배열의 확장2**

```javascript
var arr = new Array('seoul', 'new york', 'ladarkh','pusan','Tsukuba');
function getRandomValueFromArray(arr) {
    var index = Math.floor(arr.length*Math.randon());//floor메소드는 버림 연산을 하여 정수를 리.
    return result;
 } 
 console.log(getRandomValueFromArray(arr));//배열의 원소가 랜덤으로 출력된다.
```

배열 생성자에 의해 만들어진 Array의 random 메소드안에서 this는 그 배열 자체를 가리킨다. 아래의 코드는 모든 배열이 공통적으로 가지고 있어야할 메소드를 정의한다.

```javascript
Array.prototype.random = function() {
    var index = Math.floor(this.length*Math.random());//여기서 this가 의미하는 것은 var arr이 할당받은 배열 객체이다.
    return this[index];
}
var arr = new Array('seoul', 'new york', 'ladarkh','pusan','Tsukuba');
//random이라는 메소드가 Array 소속되어 있다는 것이 분명하기 때문
console.log(arr.random());
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://heunnajo.gitbook.io/javascript/undefined-3.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
