// lets say we have some object here
let range = {
from: 1,
to: 5
}
range['anyMethod'] = function(){
return 'hi from new way of creating method';
}
console.log(range.anyMethod());
// lets do the iteration from 1 to 5
range[Symbol.iterator] = function () {
return {
current: this.from,
last: this.to,
next() {
if (this.current <= this.last) {
return {done: false, value: this.current++}
} else
return {done: true}
}
}
}
// now let's iterate
for (let num of range){
console.log(num)
}
-
MY PROJECTS
-
Recent Posts
- Js.Practice.ToDoList
- CSS.Grid
- Nginx. How to return json file?
- Js.React.AddEventsOnRender
- Js.React.Handling Event in Functional Components
- Js.React.ComponentState
- Js.React.Functional and class style
- Js.React.How react renders?
- JS.EventLoop
- JS.Promise.AsyncAwaitChain
- Js.Promise.AsyncAwait
- Js. Chain of promises
- Algo.Leetcode.111. Minimum Depth of Binary Tree
- Algo. Leetcode. 104. Maximum Depth of Binary Tree
- Algo. Leetcode. 100. Same Tree
- Js.InterviewTasks.CalcNumbersInFunctions
- Delphi. Const for managed types
- SQL.Group by
- GitExtensions.SSH.PuttyClient
- Delphi. What is difference to TProcedure, TMethod = procedure of object and TAnonMethod = reference to procedure ?
Categories
- Aptana
- Azure
- C#
- DataSnap
- DBExpress
- Delphi
- Delphi и сети
- Delphi. Язык программирования
- ExtJS
- FastReport
- FireDAC
- FireMonkey
- GIT
- ICS
- IDE
- IIS
- Indy
- InnoSetup
- javascript
- jQuery
- JSON
- LiveBindings
- MSHTML
- MySQL
- PHP
- REST
- Ribbons
- SMS
- SQL инструкции
- SVN
- TRichView
- UniGui
- WebBroker
- WinAPI
- Windows
- Алгоритмы
- Без рубрики
- Деревья
- Ищу ответ
- Компонентостроение
- Мои компоненты
- Начальный уровень
- Обработка исключений
- Парсинг
- Потоки(Threads)
- Регулярные выражения
- Тестирование приложений