var data = "Tue Feb 21 2012 00:00:00 GMT+0530 (IST)"
How to slice from the string like?
var x = "Tue";
var y = "Feb";
var z = "21";
var t = "2012"
Please help?
You could use String#split with a limit for only 4 elements.
var data = "Tue Feb 21 2012 00:00:00 GMT+0530 (IST)",
array = data.split(' ', 4);
console.log(array);
With ES6, you could use a destruction assignment.
var data = "Tue Feb 21 2012 00:00:00 GMT+0530 (IST)",
[x, y, z, t] = data.split(' ', 4);
console.log(x);
console.log(y);
console.log(z);
console.log(t);