Encoding in javascript can be done by the usage of its inbuilt function
unescape() we need to encode sometimes the values say when the user input the special characters etc that the javscript doesn't take.
So to encode a string we need to use this function,
the simple code goes as:
document.write(unescape("ahsdfasjdf?asdf?^%^&%6"));
the output will be
ahsdfasjdf?asdf?^%^&%6