본문 바로가기
728x90
반응형
SMALL

programming367

method) forEach() - **Array of Numbers**: An array named `numbers` is defined, containing five numerical values: `[273, 23, 42, 152, 35]`. - **`forEach` Method**: This JavaScript method is called on the `numbers` array. The `forEach` method is used to execute a function for each element in the array. It's a part of JavaScript's `Array` prototype, making it available on all array instances. - **Callback Function**.. 2025. 1. 22.
method) getter and setter method ### Class Definition: `Square` - The `Square` class is designed to model a square with a specific length. - It uses a private field `#length` to store the square's side length. - The constructor takes an initial length for the square and sets it using the `setLength` method. - The `setLength` method updates the length of the square if the new length is greater than 0; otherwise, it throws an err.. 2025. 1. 21.
method) JSON.parse() method ### Array of Objects - The `data` constant is an array containing two objects. Each object represents a book, with properties for the book's name (`name`), price (`price`), and publisher (`publisher`). - The first object represents a book named "혼공 파이썬" with a price of 10,000 and published by "한빛미디어". - The second object represents a book named "HTML5 web programming" with a price of 20,000 and .. 2025. 1. 20.
method) JSON.stringify() method 1. **Without Formatting**: The first `console.log` call uses `JSON.stringify(data)` to convert the `data` array to a JSON string without any additional formatting. The resulting JSON string will be compact without any spaces or indentation, making it ideal for data transmission where minimizing the size is important. 2. **With Formatting**: The second `console.log` call uses `JSON.stringify(data.. 2025. 1. 19.
728x90
반응형
LIST