Why in first case it is OK and wrong in second one?
Because it's a typo! :p
It should read "array = p".
Thanks for catching this one!
Pro-tip: You should copy/paste text, it's much easier than posting a screenshot. Enclose it between backquotes to display verbatim.
p = array; // Wrong