nearestKey() lets you get the value of the keyframe that is closest to the specified time.
Passing in the variable "time" will get the key that is closest to the time indicator.
Removing keyframes transition (simulating "hold" keyframes)
Let's say we want to temporarily remove the transition between your keyframes. You could right-click your keyframes and choose "Toggle Hold Keyframes" which will do just that, but this method is destructive and you can lose your previous easing data that way.
To get around this issue we can simulate the same effect using an expression, by finding the last keyframe and sticking to its value.
Now we can remove / disable the expression in case we want to go back to our original keyframe data.