728x90 반응형 SMALL 전체 글367 method) Lodash_sortBy() method ### How the Script Works 1. **Loading Lodash**: The script tag with the `src` attribute includes Lodash from a CDN (Content Delivery Network), making the Lodash functions available for use in the script that follows. 2. **Array of Books**: An array named `books` is declared, containing objects. Each object represents a book, with properties for the book's name (`name`), price (`price`), and publ.. 2025. 1. 18. method) map() method 1. **Initialization of the Array**: An array named `numbers` is initialized with five integer values: 124, 235, 356, 546, and 23. 2. **Mapping to Square Values**: The `numbers` array is then transformed using the `map` function. For each element in the array, the function takes the element's value (`value`) and its index (`index`), squares the value (`value * value`), and returns this squared va.. 2025. 1. 17. method) Math.random() method ### Generating a Base Random Number - `const num = Math.random()` generates a base random floating-point number between 0 (inclusive) and 1 (exclusive). ### Scaling the Random Number - The script first demonstrates how to scale this base number to different ranges: - Multiplying `num` by 10 to get a range of 0 to just under 10. - Multiplying `num` by 50 to get a range of 0 to just under 50. ### .. 2025. 1. 16. method) prototype method ### Extending `Number.prototype` - A method `power` is added to `Number.prototype`, enabling any number to calculate its power. By default, it calculates the square (`n=2`), but it can take any exponent `n`. - Examples provided (`a.power()`, `a.power(3)`, `a.power(4)`) show using this method to compute the square, cube, and fourth power of a number `12`. ### Extending `String.prototype` and `Arr.. 2025. 1. 15. 이전 1 2 3 4 5 6 7 ··· 92 다음 728x90 반응형 LIST