Created
November 20, 2019 13:39
-
-
Save ramazankanbur/104a80e53b5c6164ed2a089731ab56b3 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
| ///// Array ///// | |
| //ES5 | |
| var nameArrayEs5 = ["ramazan","duygu"]; | |
| var newArrayEs5 = ["enis","kübra"].concat(nameArrayEs5); | |
| console.log(newArrayEs5); | |
| //output | |
| [ 'enis', 'kübra', 'ramazan', 'duygu' ] | |
| //ES6-spread | |
| var nameArray = ["ramazan","duygu"]; | |
| var newArray= [...nameArray, "enis","kübra"]; | |
| console.log(newArray); | |
| //output | |
| [ 'ramazan', 'duygu', 'enis', 'kübra' ] | |
| ///// Object ///// | |
| //ES5 | |
| var addressInfo = { | |
| city: "istanbul", | |
| district:"bahçelievler" | |
| }; | |
| var userInfo = { | |
| name: "ramazan", | |
| surname: "kanbur" | |
| }; | |
| for (var prop in userInfo) { addressInfo[prop] = userInfo[prop]; } | |
| console.log(addressInfo); | |
| //ES6-spread | |
| var addressInfoEs6 = { | |
| city: "istanbul", | |
| district:"bahçelievler" | |
| }; | |
| var userInfoEs6 = { | |
| name: "ramazan", | |
| surname: "kanbur" | |
| }; | |
| var mergedObject ={...addressInfoEs6,...userInfoEs6}; | |
| console.log(mergedObject); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment