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/']
Try this:

```
var array = [1, 55, 77, 88, 76, 59];
var array_last_five;
array_last_five = array.slice(-5);
if (array.length < 6) {
     array_last_five.shift();
}

```
You can do it in one line like this:

```js
const y = [1,2,3,4,5,6,7,8,9,10];
const lastX = 5;
const res = y.filter((val, index, arr) => index > arr.length - lastX - 1);

console.log(res);
```

```
.filter((val, index, arr) => index > arr.length - 6)

```