전체 글345 [JavaScript] Set Object The Set object lets you store unique values of any type, whether primitive values or object references. Create an Set Object The Set constructor creates a Set object. const set = new Set(); // Set(0) {} const set = new Set([1, 2, 3, 3]); // Set(3) {1, 2, 3} const set = new Set('Hello'); // Set(4) {'H', 'e', 'l', 'o'} Set objects consider that all NaNs are the same. console.log(NaN === NaN); // f.. 2022. 7. 13. [JavaScript] String Object The String object is used to represent and manipulate a sequence of characters. Create a String The string constructor creates an instance by type coercion an argument into a string. const strObj = new String(); const strObj = new String('HoYa'); const strObj = new String(123); // '123' If we don't use the new operator, it is converted to a string and returned. String(1); // '1' String(NaN); // .. 2022. 7. 10. [JavaScript] RegExp Object The RegExp object is used for matching text with a pattern. It introduced PCRE from ES3. Create a Regular Expression RegExp instance can be created by the constructor or literal notation. Please see the 3 ways below. const re = /ab+c/i; const re = new RegExp('ab+c', 'i'); const re = new RegExp(/ab+c/, 'i')); The pattern syntax is below. /PATTERN/FLAG / symbol means to start and end. In other wor.. 2022. 7. 9. [JavaScript] Date Object The Date object represents a single moment in time in a platform-independent format. It contains a Number that represents milliseconds since 1970/01/01 00:00:00 UTC. There is a difference in the result representation depending on the browser environment and node.js environment. Date Constructor There are 4 ways to create a Date instance. new Date() It returns a date instance with the current dat.. 2022. 7. 9. [JavaScript] Math Object Math is a standard built-in object that has only static properties and static methods for mathematical constants and functions. It works with the Number type and doesn't work with the BigInt type. Math Property E This property is Euler's constant. Math.E; // 2.718281828459045 LN2 This property is a natural logarithm of 2. Math.LN2; // 0.6931471805599453 LN10 This property is a natural logarithm .. 2022. 7. 8. [JavaScript] Number Object The Number object is a standard built-in object that is useful when handling the primitive type of numbers. Number Definition We can create an instance whose type is the Number using the Number() constructor. const numObj = new Number(); // [Number: 0] const numObj = new Number(10); // [Number: 10] const numObj = new Number('10'); // [Number: 10] const numObj = new Number('test'); // [Number: Na.. 2022. 7. 7. [JavaScript] Array Arrays in JS are sparse array that is not continuously connected in memory. Compared to a typical array, accessing the index is fast, and inserting/deleting is slow. Neither JS arrays' length nor its elements' types are fixed. Create Arrays There are 4 ways to create arrays. Array Literal const arr1 = [1, 2, 3]; const arr2 = ["apple", 2, "carrot", 4]; Array Constructor const arr = new Array(3); .. 2022. 7. 6. [JavaScript] Class From ES6, JS has class. JS is a prototype-based language. Therefore, classes in JS are slightly different from those in other object-oriented languages. A class is basically a data type that collected variables and methods for similar purposes. Class Declaration A statement or expression can declare classes. Both anonymous and named declarations are possible in expression. class Person {} const .. 2022. 7. 1. [JavaScript] Object Objects of JS are a collection of related data and/or functionality. Objects can have multiple primitive types of values. The primitive type of value is immutable, but the object type of value is mutable. Property An object is a set of zero or more properties, and the property consists of a key and a value. If the value of the property is a function, it is called a method. Key Key can be string .. 2022. 6. 26. 이전 1 ··· 7 8 9 10 11 12 13 ··· 39 다음