DEV Community

Siddharth Kanojiya
Siddharth Kanojiya

Posted on

JavaScript Array Methods # 14

// Array Methods
let num = [1, 2, 3, 34, 4]
let b = num.toString() // b is string now
console.log(b,typeof b)
let c = num.join("_")
console.log(c,typeof c)
num.pop()
console.log(num)
// let r = num.pop()// pop return the poped element
// console.log(num, r)
// let r = num.push(69)// push return the new array length
// console.log(num, r)
// let r = num.shift()// Remove an element from the start arry
// console.log(r, num)
let r = num.unshift(69)// Remove an element from the start arry
console.log(r, num)

Top comments (0)