Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

How to convert the following Java code to JScript:

return ((IPOSBasket) basket).getOriginalCashierID();

When executing the above code in Java, it works fine. But if I try to execute as a JScript, I am getting NULL value.

share|improve this question
2  
stackoverflow.com/a/245068/2454376 –  mishik Jul 10 '13 at 8:03
    
haha, great answer! –  Jamie Hutber Jul 10 '13 at 8:04
1  
Are you talking about JScript or Javascript? –  mthmulders Jul 10 '13 at 8:07
1  
If it is jScript, are you using it to compile .net assemblies? en.wikipedia.org/wiki/JScript_.NET That jScript is typed. Ecma javascript and jscript in IE are not typed so there is no need for conversion (unless you need string to number). –  HMR Jul 10 '13 at 8:13
1  
In case you try to run this script in a browser then return basket.getOriginalCashierID(); will do. –  HMR Jul 10 '13 at 8:17

3 Answers 3

At the risk of getting downvotes XD

Java and Javascript are similar like Car and Carpet are similar.

Greg Hewgill 2008

share|improve this answer
    
Well copied from a question that was mentioned in the comments already... –  mthmulders Jul 10 '13 at 8:07

You shouldn't need to cast anything, how are you getting the basket variable?

Also, as a good practice don't do any operations in a return statement, it sometimes hides errors/problems in code and harms readability.

So if it is JScript:

var basket : IPOSBasket = IPOSBasket(x); // this is made up, don't know what you are doing here.
var originalCashierID = basket.getOriginalCashierID();
return originalCashierID;
share|improve this answer
up vote 0 down vote accepted

As mentioned by HMR in comment, the following line works fine:

return basket.getOriginalCashierID();
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.