분류 전체보기
-
First-Class Object and High-Order functionDynamicPL/Python 2019. 11. 2. 14:02
1. Overview In programming language design, a first-class citizen (also type, object, entity, or value) in a given programming language is an entity that supports all the operations generally available to other entities. These operations typically include being passed as an argument, returned from a function, modified, and assigned to a variable. In mathematics and computer science, a higher-ord..
-
SliceDynamicPL/Python 2019. 10. 28. 15:54
1. Overview Slicing relies on indexing. It only works with sequence types. 2. Description 2.1 Capability on sequence types 2.2 Sequence type 2.3 Slice start and stop bounds 2.4 Step value 2.5 Range equivalence 2.6 Transformation [i:j] 2.7 Transformations [i:j:k], k > 0 2.8 Transformations [i:j:k], k < 0 2.9 indices method 2.10 Summary 3. Example 3.1 Example 1 3.2 Example 2 4. References https://..
-
SequenceDynamicPL/Python 2019. 10. 26. 16:26
1. Definition In Math: $S=x_{1},x_{2},x_{3},\cdots $ Note The sequence of indices: 1, 2, 3, ... We can refer to any item in the sequence by using its index number S[2] So we have a concept of the first element, the second element, and so on Python lists have a concept of positional order, but set do not A list is a sequence type A set is not a sequence type 2. Built-In Sequence Types 2.1 Mutable..
-
Destructuring, Spread, Rest parameters, Default parameters, Maps and ArraysDynamicPL/Javascript 2019. 10. 24. 19:28
1. Overview There are several new features added in ES6 which are Destructing, Spread, Rest, Default parameter, and so on. 2. Description 2.1 Destructing // ES5 var john = ['John', 26]; //var name = john[0]; //var age = john[1]; // ES6 // assign each element to variable const [name, age] = ['John', 26]; console.log(name); console.log(age); const obj = { firstName: 'John', lastName: 'Smith' }; co..
-
Arrow functionDynamicPL/Javascript 2019. 10. 24. 17:43
1. Overview Arrow functions which are added in ES6 are so simple and share the surrounding this keyword. Unlike normal function, arrow functions don't get their own "this" keyword. 2. Description 2.1 Expression const years = [1990, 1965, 1982, 1937]; // ES5 var ages5 = years.map(function(el) { return 2016 - el; }); console.log(ages5); // ES6 // a lots less code let ages6 = years.map(el => 2016 -..
-
let, const, block scope, function scope and IIFEsDynamicPL/Javascript 2019. 10. 24. 15:05
1. Overview Variables declared with var in ES5 are function-scoped and Variables declared with let and const in ES6 are block-scoped. 2. Description 2.1 Function-scoped Variables, which declared var, are only accessible inside of a function, but not from the outside. And we would use a variable before the declaration, it would be an "undefined" cause of hoisting. function driversLicence5(passedT..
-
Bind, Call and ApplyDynamicPL/Javascript 2019. 10. 24. 02:18
1. Overview Functions are a special kind of object and also get a couple of special methods that they inherit from the function constructor object such as call, apply and bind methods. These methods allow us to call a function and set this variable manually. 2. Description var john = { name: 'John', age: 26, job: 'teacher', presentation: function(style, timeOfDay) { if (style === 'formal') { con..
-
First-Class Functions and IIFEDynamicPL/Javascript 2019. 10. 24. 00:31
1. Overview We can pass functions as arguments and return it and store it into variables because functions are always first-class functions in Javascript because they are effectively objects. 2. Description 2.1 Passing Functions as Arguments These functions are called "callback function" because they are functions that we pass into functions that will then call them later. var years = [1990, 196..