2D Wall Jump Script Help

void Update()
{
if (wallSliding && !player.grounded)
{
gameObject.GetComponent().velocity = new Vector2(gameObject.GetComponent().velocity.x, -slideSpeed);
}

    if(Input.GetKeyDown(KeyCode.Space) && wallSliding)
    {
        if (player.lastVelocityX > 0)
        {
            gameObject.GetComponent<Rigidbody2D>().velocity = new Vector2(-jumpLength, jumpHeight);
        }
        else if (player.lastVelocityX < 0)
        {
            gameObject.GetComponent<Rigidbody2D>().velocity = new Vector2(jumpLength, jumpHeight);
        }
    }

}

When the player performs a wall jump he sort of teleports to the side first and then moves straight up before falling back down. If anyone can see why or maybe have a better method of doing this, it would be greatly appreciated.

You change the velocity of the object. Try applying a force to it instead.
For example, you multiply the jumping axis with the power of jumping.

gameObject.GetComponent<Rigidbody2D>().AddForce(transform.up * jumpPower);

Rigidbody.AddForce Documentation.