Created
August 3, 2016 08:55
-
-
Save deepak/2496f0a2b248c4ce3abaf2526e3d275b to your computer and use it in GitHub Desktop.
es6 spread
This file contains 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
"use strict"; | |
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | |
var state = { | |
loggedIn: false | |
}; | |
var newState = _extends({}, state, { | |
loggedIn: "test" | |
}); | |
state.loggedIn = true; | |
console.log(state); | |
console.log(newState); |
This file contains 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
const state = { | |
loggedIn: false | |
}; | |
const newState = { | |
...state, | |
loggedIn: "test" | |
} | |
state.loggedIn = true; | |
console.log(state); | |
console.log(newState); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment