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

Cross browser testing - automation framework-cypress,playwrite; CloudBorwser -saucelabs browserstack

 Evaluating cross-browser testing for a React application involves  assessing both  functional consistency  (JavaScript/API behavior) and  v...