Sunday, 27 August 2017

JS - Array - push ===unshift or pop === shift

push the value to end of an array element, unshift push the element at beging of array
pop remove the last element of an array, shift remove the first element of an array. 

<script type="text/javascript">

var myArr = [2,3];
document.write("Orginal Arr "+myArr+"<br>")
myArr.push(4);
myArr.unshift(1)
document.write("unshift 1 and push 4 "+myArr+"<br>")

myArr.pop();
myArr.shift();
document.write("shift and pop "+ myArr+"<br>")

document.write(myArr.length)
</script>

No comments:

Post a Comment

React Core Architectural princciples

Core Architectural Principles Modern React applications typically follow these foundational concepts to manage complexity:   Component-Based...