Update class.js

add two useful functions