xxxxxxxxxx
<html>
<head>
<script src="https://cdn.jsdelivr.net/gh/lodash/lodash/3.0.1/lodash.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
var cls, curCls, i, key, nodeA, nodeB, res, value, _i, _ref;
nodeA = {
className: 'txt-a txt-b bold center txt-a'
};
cls = 'add-cls';
curCls = nodeA.className.split(' ');
curCls.push(cls);
nodeA.className = _.uniq(curCls).join(' ');
console.log(nodeA);
nodeB = {
className: 'txt-a txt-b bold center txt-a'
};
cls = 'add-cls';
curCls = nodeB.className.split(' ');
curCls.push(cls);
res = {};
for (i = _i = 0, _ref = curCls.length; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) {
res[curCls[i]] = curCls[i];
}
curCls = (function() {
var _results;
_results = [];
for (key in res) {
value = res[key];
_results.push(value);
}
return _results;
})();
nodeB.className = curCls.join(' ');
console.log(nodeA, nodeB, nodeA.className === nodeB.className);
</script>
<script id="jsbin-source-javascript" type="text/javascript">nodeA =
className: 'txt-a txt-b bold center txt-a'
cls = 'add-cls'
curCls = nodeA.className.split(' ')
curCls.push(cls)
nodeA.className = _.uniq(curCls).join(' ')
console.log nodeA
nodeB =
className: 'txt-a txt-b bold center txt-a'
cls = 'add-cls'
curCls = nodeB.className.split(' ')
curCls.push(cls)
res = {}
res[curCls[i]] = curCls[i] for i in [0...curCls.length]
curCls = for key, value of res then value
nodeB.className = curCls.join(' ')
console.log nodeA, nodeB , nodeA.className is nodeB.className
</script></body>
</html>
Updated missing url https://rawgit.com/lodash/lodash/3.0.1/lodash.min.js to https://cdn.jsdelivr.net/gh/lodash/lodash/3.0.1/lodash.min.js
https://rawgit.com/lodash/lodash/3.0.1/lodash.min.js