Created
November 11, 2019 13:05
-
-
Save ramazankanbur/5d7a20547eb0142a3da349067d3e8b63 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //ES5 that, this ataması yapılmalı ya da bind edilmeli | |
| var obj = { | |
| nums: [1, 2, 3, 4, 5, 6, 10], | |
| fives: [], | |
| hop: function() { | |
| var that = this; | |
| this.nums.forEach(function(v) { | |
| if(v % 5 ===0) | |
| that.fives.push(v); | |
| }); | |
| console.log(this.fives); | |
| } | |
| }; | |
| obj.hop(); | |
| console.log('----------------------'); | |
| //ES6 | |
| var obj1 = { | |
| nums: [1, 2, 3, 4, 5, 6, 10], | |
| fives: [], | |
| hop:function () { | |
| this.nums.forEach((v) => { | |
| if(v % 5 ===0) | |
| this.fives.push(v); | |
| }); | |
| console.log(this.fives); | |
| } | |
| }; | |
| obj1.hop(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment