예전 카페에서 폐지 공지가 와서 자료를 옮겨 놓습니다.
자바스크립트 내장함수(06.08.11)
alert ;
alert함수는 메시지와 OK버튼만을 가진 다이얼로그 박스를 보여주는 함수로 사용자의 요구를 받을 필요가 없는 메시지의 경우에 사용.(인사말 같은것)
confirm ;
confirm함수는 메시지와 OK/Cancel버튼을 포함한 다이얼러그 박스를 보여주는 함수로 사용자로부터 응답을 듣고 싶을 때 사용하고 사용자가 OK버튼을 누르면 true가 리턴되고 Cancel버튼을 누르면 false를 리턴
prompt ;
메시지와 입력필드를 가진 다이얼로그 박스를 보여주는 함수로 사용자로부터 숫자나 문자열을 입력받아 할 때 사용하는 함수.
eval ;
eval함수는 문자열로 입력된 수식을 계산하여 주는 함수로 예를 들 "12+3"과 같은 문자열을 eval함수의 매개변수로 입력하면 문자열을 수식으로 변환한 후 계산을 하여 "5"라는 정수를 리턴해 줌. 이 함수는 입력양식을 통해 입력받은 수식을 처리할 때 유용하게 사용 할 수 있음.
parseint ;
parseint는 문자열을 정수로 바꿔주는 내장함수로 입력된 문자열을 2진수,8진수,16진수 정수로 바꿔준다.
parseint(string,nBase)의 형태로사용하는데 첫 번째 매개변수 string에 변환할 문자열을 입력하고ㅡ nBase에 변환할 정수의 형태를 지정한다.
parsefloat ;
parsefloat는 문자열을 부동소수점으로 바꾸는 내장함수로 parsefloat(string)의형태로 사용된다
2025.5.10 요약 반영
1. 전역함수 (Global Functions)
이 함수들은 어떤 객체에도 속하지 않고 어디서든 바로 호출할 수 있어요.
eval(): 문자열로 표현된 JavaScript 코드를 실행합니다. (Executes a string as JavaScript code.)
parseInt(): 문자열을 정수로 변환합니다. (Parses a string and returns an integer.)
parseFloat(): 문자열을 부동 소수점 수로 변환합니다. (Parses a string and returns a floating-point number.)
isNaN(): 값이 NaN (Not-a-Number)인지 판별합니다. (Determines whether a value is NaN.)
isFinite(): 값이 유한한 수인지 판별합니다. (Infinity나 -Infinity, NaN이 아닌지 확인합니다.) (Determines whether a value is a finite number.)
encodeURI(): URI (Uniform Resource Identifier)를 인코딩하여 예약 문자를 이스케이프 처리합니다. (Encodes a URI by replacing certain characters with escape sequences.)
encodeURIComponent(): URI의 구성 요소를 인코딩합니다. encodeURI()보다 더 많은 문자를 이스케이프 처리합니다. (Encodes a URI component by replacing certain characters with escape sequences.)
decodeURI(): encodeURI()로 인코딩된 URI를 디코딩합니다. (Decodes a URI encoded by encodeURI().)
decodeURIComponent(): encodeURIComponent()로 인코딩된 URI 구성 요소를 디코딩합니다. (Decodes a URI component encoded by encodeURIComponent().)
Number(): 값을 숫자로 변환합니다. (Converts a value to a number.)
String(): 값을 문자열로 변환합니다. (Converts a value to a string.)
Boolean(): 값을 불리언 값으로 변환합니다. (Converts a value to a boolean.)
Symbol(): 새로운 Symbol 값을 생성합니다. (Returns a new Symbol value.)
Object(): 새로운 객체를 생성합니다. (Creates a new object.)
2. 객체 관련 함수(Object Related Functions )
이 함수들은 Object 객체와 관련된 다양한 작업을 수행합니다.
Object.keys(obj): 주어진 객체의 속성 이름(키)들을 배열로 반환합니다. (Returns an array of a given object's own enumerable property names.)
Object.values(obj): 주어진 객체의 속성 값들을 배열로 반환합니다. (Returns an array of a given object's own enumerable property values.)
Object.entries(obj): 주어진 객체의 [key, value] 쌍들을 담은 배열을 반환합니다. (Returns an array of a given object's own enumerable string-keyed property [key, value] pairs.)
Object.assign(target, ...sources): 하나 이상의 원본 객체로부터 대상 객체로 속성을 복사합니다. (Copies the values of all enumerable own properties from one or more source objects to a target object.)
Object.create(prototype, propertiesObject): 지정된 프로토타입 객체 및 속성을 갖는 새로운 객체를 생성합니다. (Creates a new object with the specified prototype object and properties.)
Object.defineProperty(obj, prop, descriptor): 객체에 새로운 속성을 직접 정의하거나, 기존 속성의 정의를 수정합니다. (Defines a new property directly on an object, or modifies an existing property on an object, and returns the object.)
Object.defineProperties(obj, props): 객체에 여러 개의 새로운 속성을 직접 정의하거나, 기존 속성의 정의를 수정합니다. (Defines new or modifies existing properties directly on an object, returning the object.)
Object.getOwnPropertyDescriptor(obj, prop): 객체의 특정 속성에 대한 속성 설명자(descriptor)를 반환합니다. (Returns a property descriptor for an own property (that is, one directly present on an object and not in the object's prototype chain) of a given object.)
Object.getOwnPropertyNames(obj): 객체의 모든 속성 이름(열거 불가능한 속성 포함)을 배열로 반환합니다. (Returns an array of all properties (enumerable or not) found directly upon a given object.)
Object.getPrototypeOf(obj): 지정된 객체의 프로토타입 객체를 반환합니다. (Returns the prototype (i.e., the internal [[Prototype]] property) of the specified object.)
Object.setPrototypeOf(obj, prototype): 지정된 객체의 프로토타입을 설정합니다. (Sets the prototype (i.e., the internal [[Prototype]] property) of a specified object to another object or null.)
Object.is(value1, value2): 두 값이 같은 값인지 판별합니다. (=== 연산자와 유사하지만 몇 가지 예외적인 경우를 처리합니다.) (Determines whether two values are the same value.)
Object.seal(obj): 객체를 밀봉합니다. 새로운 속성 추가 및 기존 속성 삭제를 방지하고, 기존 속성의 속성 설명자 수정도 방지하지만, 속성 값은 변경 가능합니다. (Seals an object, preventing new properties from being added to it and marking all existing properties as non-configurable.)
Object.freeze(obj): 객체를 동결합니다. 밀봉된 객체의 모든 속성을 읽기 전용으로 만듭니다. (Freezes an object. A frozen object can no longer have new properties added to it; existing properties can no longer be removed; existing properties can no longer have their enumerability, configurability, or writability changed; and also the values of existing properties cannot be changed.)
Object.isSealed(obj): 객체가 밀봉되었는지 확인합니다. (Determines if an object is sealed.)
Object.isFrozen(obj): 객체가 동결되었는지 확인합니다. (Determines if an object is frozen.)
Object.hasOwnProperty(prop): 객체가 특정 속성을 직접 소유하고 있는지 (프로토타입 체인에서 상속받은 것이 아닌) 불리언 값으로 반환합니다. (Returns a boolean indicating whether the object has the specified property as its own property (as opposed to inheriting it).)
Object.prototype.toString(): 객체의 문자열 표현을 반환합니다. (Returns a string representing the object.)
Object.prototype.valueOf(): 객체의 원시 값을 반환합니다. (Returns the primitive value of the specified object.)
3. 배열 관련 함수 (Array Related Functions)
이 함수들은 Array 객체의 메서드로 배열을 조작하고 관리하는 데 사용됩니다.
Array.isArray(obj): 주어진 값이 배열인지 판별합니다. (Determines whether the passed value is an Array.)
Array.from(arrayLike, mapFn, thisArg): 유사 배열 객체나 반복 가능한 객체로부터 새로운 Array 인스턴스를 만듭니다. (Creates a new Array instance from an array-like or iterable object.)
Array.of(...elements): 인수의 수나 타입에 관계없이 가변적인 수의 인수로 새로운 Array 인스턴스를 만듭니다. (Creates a new Array instance with a variable number of arguments, regardless of number or type of the arguments.)
Array.prototype.push(...elements): 배열의 끝에 하나 이상의 요소를 추가하고, 새로운 배열의 길이를 반환합니다. (Adds one or more elements to the end of an array and returns the new length of the array.)
Array.prototype.pop(): 배열의 마지막 요소를 제거하고 그 요소를 반환합니다. 배열이 비어있으면 undefined를 반환합니다. (Removes the last element from an array and returns that element. This method changes the length of the array.)
Array.prototype.unshift(...elements): 배열의 시작 부분에 하나 이상의 요소를 추가하고, 새로운 배열의 길이를 반환합니다. (Adds one or more elements to the beginning of an array and returns the new length of the array.)
Array.prototype.shift(): 배열의 첫 번째 요소를 제거하고 그 요소를 반환합니다. 배열이 비어있으면 undefined를 반환합니다. (Removes the first element from an array and returns that element. This method changes the length of the array.)
Array.prototype.slice(begin, end): 배열의 begin부터 end 직전까지의 요소를 얕게 복사하여 새로운 배열 객체로 반환합니다. (Returns a shallow copy of a portion of an array into a new array object selected from begin to end (end not included).)
Array.prototype.splice(start, deleteCount, ...items): 배열의 기존 요소를 삭제 또는 교체하거나 새 요소를 추가하여 배열의 내용을 변경합니다. (Changes the contents of an array by removing or replacing existing elements and/or adding new elements in place.)
Array.prototype.concat(...arrays): 기존 배열에 하나 이상의 배열 또는 값을 합쳐서 새로운 배열을 반환합니다. (Returns a new array consisting of the array on which it is called, joined with the array(s) and/or value(s) provided as arguments.)
Array.prototype.join(separator): 배열의 모든 요소를 지정된 구분 기호로 연결한 문자열을 반환합니다. (Creates and returns a new string by concatenating all of the elements in an array (or an array-like object), separated by commas or a specified separator string.)
Array.prototype.reverse(): 배열의 요소 순서를 반전시킵니다. (Reverses the order of the elements in an array in place. The first element becomes the last, and the last element becomes the first.)
Array.prototype.sort(compareFunction): 배열의 요소를 제자리에서 정렬하고 정렬된 배열을 반환합니다. (Sorts the elements of an array in place and returns the sorted array. The default sort order is ascending, built upon converting the elements into strings, then comparing their sequences of UTF-16 code units values.)
Array.prototype.indexOf(searchElement, fromIndex): 배열에서 지정된 요소를 찾을 수 있는 첫 번째 인덱스를 반환하고, 찾을 수 없으면 -1을 반환합니다. (Returns the first index at which a given element can be found in the array, or -1 if it is not present.)
Array.prototype.lastIndexOf(searchElement, fromIndex): 배열에서 지정된 요소를 찾을 수 있는 마지막 인덱스를 반환하고, 찾을 수 없으면 -1을 반환합니다. (Returns the last index at which a given element can be found in the array, or -1 if it is not present.)
Array.prototype.includes(valueToFind, fromIndex): 배열이 특정 값을 포함하고 있는지 여부를 불리언 값으로 반환합니다. (Determines whether an array includes a certain value among its entries, returning true or false as appropriate.)
Array.prototype.forEach(callback(currentValue, index, array), thisArg): 배열의 각 요소에 대해 제공된 함수를 한 번씩 실행합니다. (Executes a provided function once for each array element.)
Array.prototype.map(callback(currentValue, index, array), thisArg): 배열의 각 요소에 대해 제공된 함수를 호출한 결과를 모아 새로운 배열을 반환합니다. (Creates a new array populated with the results of calling a provided function on every element in the calling array.)
Array.prototype.filter(callback(element, index, array), thisArg): 제공된 함수에 의해 구현된 테스트를 통과하는 모든 요소를 사용하여 새로운 배열을 만듭니다. (Creates a new array with all elements that pass the test implemented by the provided function.)
Array.prototype.reduce(callback(accumulator, currentValue, currentIndex, array), initialValue): 배열의 각 요소에 대해 제공된 "reducer" 콜백 함수를 실행하여 단일 값으로 줄입니다. (Executes a reducer function (that you provide) on each element of the array, resulting in a single output value.)
Array.prototype.reduceRight(callback(accumulator, currentValue, currentIndex, array), initialValue): 배열의 각 요소에 대해 제공된 함수를 오른쪽에서 왼쪽으로 적용하여 단일 값으로 줄입니다. (Applies a function against an accumulator and each value of the array (from right-to-left) to reduce it to a single value.)
Array.prototype.every(callback(element, index, array), thisArg): 배열의 모든 요소가 제공된 함수로 구현된 테스트를 통과하는지 확인합니다. (Tests whether all elements in the array pass the test implemented by the provided function. It returns a Boolean value.)
Array.prototype.some(callback(element, index, array), thisArg): 배열의 적어도 하나의 요소가 제공된 함수로 구현된 테스트를 통과하는지 확인합니다. (Tests whether at least one element in the array passes the test implemented by the provided function. It returns a Boolean value.)
Array.prototype.find(callback(value, index, obj), thisArg): 배열에서 제공된 테스트 함수를 만족하는 첫 번째 요소의 값을 반환합니다. 그렇지 않으면 undefined를 반환합니다. (Returns the value of the first element in the provided array that satisfies the provided testing function. If no values satisfy the testing function, undefined is returned.)
Array.prototype.findIndex(callback(value, index, obj), thisArg): 배열에서 제공된 테스트 함수를 만족하는 첫 번째 요소의 인덱스를 반환합니다. 그렇지 않으면 -1을 반환합니다. (Returns the index of the first element in the array that satisfies the provided testing function. Otherwise -1 is returned.)
Array.prototype.fill(value, start, end): 배열의 start 인덱스부터 end 인덱스 이전까지의 모든 요소를 정적 값으로 채웁니다. (Fills (modifies) all the elements of an array from a start index (default 0) to an end index (default array.length) with a static value.)
Array.prototype.copyWithin(target, start, end): 배열 내의 일부를 얕게 복사하여 동일한 배열의 다른 위치에 덮어쓰고 크기를 수정하지 않고 반환합니다. (Shallow copies part of an array to another location in the same array and returns the modified array without modifying its length.)
Array.prototype.entries(): 배열의 각 인덱스에 대한 [키, 값] 쌍을 포함하는 새로운 Array Iterator 객체를 반환합니다. (Returns a new Array Iterator object that contains the key/value pairs for each index in the array.)
Array.prototype.keys(): 배열의 각 인덱스에 대한 키를 포함하는 새로운 Array Iterator 객체를 반환합니다. (Returns a new Array Iterator object that contains the keys for each index in the array.)
Array.prototype.values(): 배열의 각 인덱스에 대한 값을 포함하는 새로운 Array Iterator 객체를 반환합니다. (Returns a new Array Iterator object that contains the values for each index in the array.)
4. 문자열 관련 함수 (String Related Functions)
이 함수들은 String 객체의 메서드로 문자열을 조작하고 관리하는 데 사용됩니다.
String(): 주어진 값을 문자열로 변환하는 생성자입니다. (A constructor that creates a String object.)
String.fromCharCode(...codes): 지정된 유니코드 값을 갖는 문자열을 반환합니다. (Returns a string created by using the specified sequence of Unicode values.)
String.fromCodePoint(...codePoints): 지정된 코드 포인트 시퀀스에서 생성된 문자열을 반환합니다. (Returns a string created by using the specified sequence of code points.)
String.prototype.charAt(index): 문자열에서 지정된 인덱스에 있는 문자를 반환합니다. (Returns the character (exactly one UTF-16 code unit) at the specified index.)
String.prototype.charCodeAt(index): 문자열에서 지정된 인덱스에 있는 문자의 유니코드 값을 반환합니다. (Returns the Unicode value of the character at the specified index.)
String.prototype.codePointAt(pos): 문자열에서 지정된 위치에 있는 코드 포인트 값을 나타내는 음이 아닌 정수를 반환합니다. (Returns a non-negative integer that is the Unicode code point value starting at the given index.)
String.prototype.concat(...strings): 호출한 문자열에 하나 이상의 문자열을 연결한 새로운 문자열을 반환합니다. (Returns a new string containing the combined text of the string on which it was called and one or more other strings provided as arguments.)
String.prototype.includes(searchString, position): 문자열이 다른 문자열을 포함하고 있는지 여부를 불리언 값으로 반환합니다. (Determines whether one string may be found within another string, returning true or false as appropriate.)
String.prototype.endsWith(searchString, length): 문자열이 다른 문자열의 문자로 끝나는지 여부를 불리언 값으로 반환합니다. (Determines whether a string ends with the characters of a specified string, returning true or false as appropriate.)
String.prototype.startsWith(searchString, position): 문자열이 다른 문자열의 문자로 시작하는지 여부를 불리언 값으로 반환합니다. (Determines whether a string begins with the characters of a
'프로그램 > java' 카테고리의 다른 글
nodeJs, express 프로젝트 테스트 (16.05.11) (2025.5.23 update) (1) | 2025.05.23 |
---|---|
mean 개발환경 셋팅 (16.05.10) (2) | 2025.05.23 |
rmi+mysql (06.02.07) (0) | 2025.05.13 |
java.awt (2005.04.04) Swing (2025.05.13 Update) (0) | 2025.05.13 |
자바 기초(2) 클래스 (2005.04.04)(2025.05.13 Update) (0) | 2025.05.13 |