I have a custom control with a panel wrapping all the other controls. The control is in one of two states, edit-mode and normal. When in edit-mode I want the control to have the option of a different background color. 

I have:

In Pre\_Render:

```
Panel1.BackColor = EditMode ? BackEditColor : BackColor;

```

And the control properties:

```
[Bindable(true)]
[Category("Misc")]
[Description("The background color.")]
[DefaultValue("white")]
[Localizable(true)]
public Color BackColor
{
    get { return Color.FromName(Convert.ToString(ViewState["BackColor"] ?? "white")); }
    set { ViewState["BackColor"] = value.Name; }
}

[Bindable(true)]
[Category("Misc")]
[Description("The edit-mode background color.")]
[DefaultValue("#FFFFCC")]
[Localizable(true)]
public Color BackEditColor
{
    get { return Color.FromName(Convert.ToString(ViewState["BackEditColor"] ?? "#FFFFCC")); }
    set { ViewState["BackEditColor"] = value.Name; }
}

```

I can set the colors with no problem via the control's properties, but they only show as white on render. How should I be saving/reading to ViewState the colors?
['https://Stackoverflow.com/questions/6473882', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/353147/']
Here is one I haven't seen that's even shorter

```
arr.slice(1).slice(-5)

```

Run the code snippet below for proof of it doing what you want

```js
const arr = [];
for (let i = 0; i < 8; i++) {
    arr.push(i);
    console.log(`Array ${i + 1}: ${arr} -> ${arr.slice(1).slice(-5)}`);
}
```

Another way to do it would be using lodash <https://lodash.com/docs#rest> - that is of course if you don't mind having to load a huge JavaScript minified file if you're trying to do it from your browser.

```
_.slice(_.rest(arr), -5)

```
ES6 way:

I use [destructuring assignment](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment) for array to get `first` and remaining `rest` elements and then I'll take last five of the `rest` with [slice](https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/Array/slice) method:

```js
const cutOffFirstAndLastFive = (array) => {
  const [first, ...rest] = array;
  return rest.slice(-5);
}

cutOffFirstAndLastFive([1, 55, 77, 88]);

console.log(
  'Tests:',
  JSON.stringify(cutOffFirstAndLastFive([1, 55, 77, 88])),
  JSON.stringify(cutOffFirstAndLastFive([1, 55, 77, 88, 99, 22, 33, 44])),
  JSON.stringify(cutOffFirstAndLastFive([1]))
);
```